SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Is command length limited by SQLCommand?


Is command length limited by SQLCommand?

Author
Message
peo_gt
peo_gt
Valued Member
Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)

Group: General Forum Members
Points: 50 Visits: 27
I have a table with a varchar(max) column to store a large configuration text string (it really a xml file but I need to have in a table).
Working in .Net I use an SQLCommand object to insert the data.
A varchar(max) field is supposed to take 2GB of data, but when my data exceeds about 65000 characters, the field remains blank.
The key colums are inserted, no error is detected, the varcahr(max) column just remains blank.
If I truncate my data string to 65000 it works fine, but 70000 does not (I have not tried 65535 :-))

Server is 2008R2 Express

/PeO
peo_gt
peo_gt
Valued Member
Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)

Group: General Forum Members
Points: 50 Visits: 27
It is SQL Server Management Studio that doesn't show data longer than 65535 bytes.
A "real" readback showed that the data was in the table as expected.
/PeO
Jim McLeod
Jim McLeod
Hall of Fame
Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)

Group: General Forum Members
Points: 3839 Visits: 1121
Yep - you got it. There's a setting in Management Studio - Tools, Options, Query Results, SQL Server, Results To Grid, Maximum Characters Retrieved - Non XML Data, which defaults to 64KB.

The maximum batch size is 65536 * Network Packet Size (sp_configure 'network packet size (B)'), which is usually 4 KB, but can be 0.5-32KB. At the default, this means a maximum batch size of 256 MB. At the maximum, 2 GB.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum









































































































































































SQLServerCentral


Search