1

I am trying to concatenate a list of IDs into a varchar(max) to pass into an openquery for a bulk update of data.

My question is, is there an easy way to see if a string is beyond the length a varchar(max) can handle aside from comparing it to the number?

I have seen this: How many characters in varchar(max) which specifies the exact length of a varchar(max), but I was hoping for a simpler method than comparing length to a static numeric value.

Please let me know if any more information is needed.

Community
  • 1
  • 1
Phil
  • 498
  • 6
  • 14

2 Answers2

3

The max length of varchar(max) is 2GB however openquery only takes 8K according to Books On Line

OPENQUERY (linked_server ,'query') Arguments linked_server Is an identifier representing the name of the linked server.

'query' Is the query string executed in the linked server. The maximum length of the string is 8 KB.

SQLMenace
  • 132,095
  • 25
  • 206
  • 225
  • 1
    I hadn't even thought of the max length of the openquery. Thanks a lot for your help! – Phil Jun 04 '10 at 14:50
0

If you are using the sql server you can use print(@sql) at the end, and it will indicate where you have reached the maximum amount of characters. I had reached the maximum amount and to delete some extra space where there was no special characters, and it worked.

lemon
  • 14,875
  • 6
  • 18
  • 38