SetDatabaseString() with 'text' data type with MS-SQL.

Just starting out? Need help? Post your questions and find answers here.
Seldon
Enthusiast
Enthusiast
Posts: 405
Joined: Fri Aug 22, 2003 7:12 am
Location: Italia

SetDatabaseString() with 'text' data type with MS-SQL.

Post by Seldon »

Hi,

I don't know if this is really a bug or a behaviour by design, but if you have to insert a string into a 'text' data type in MS-SQL (only tried on EXPRESS edition) using SetDatabaseString(), you are limited to a maximum of 8000 bytes (4000 characters with Unicode). So, if you must insert a larger string, avoid using bound variables... actually if you build the string directly in the query, it works! I hope this can be usefull for someone to save time and looking for a bug (just like it was for me). :)

Cheers!
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: SetDatabaseString() with 'text' data type with MS-SQL.

Post by skywalk »

Really big strings should be inserted with BLOB.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Seldon
Enthusiast
Enthusiast
Posts: 405
Joined: Fri Aug 22, 2003 7:12 am
Location: Italia

Re: SetDatabaseString() with 'text' data type with MS-SQL.

Post by Seldon »

In my case, the target database is not mine so I can't change any field. Can I use SetDatabaseBlob() into a 'text' field ? My program is just an import tool, the database then is handled by it own application.
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: SetDatabaseString() with 'text' data type with MS-SQL.

Post by skywalk »

Hmm, I have not tried but you can find out quick enough. :wink:
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: SetDatabaseString() with 'text' data type with MS-SQL.

Post by Fred »

I checked and there is no hard limit on SetDatabaseString(), so it's probably the driver which is cutting it. SQL Server short string column is limited to 8000 bytes which exactly match your finding:
https://learn.microsoft.com/en-us/sql/s ... rver-ver16
Post Reply