I’ve been looking all over for an answer to this, but nothing is explicit so hopefully someone knows off the top of their head.
When using EXECUTE with a VARCHAR(MAX) variable, is there a character limit? I’ve done some experimenting and it seems that when load a variable and then call EXECUTE @var, there is a character limit on what is actually passed through to the server. When calling EXECUTE without the variable and just building the string there, everything appears to work…. is there a reason for this? The error message returned is:
The Name ‘ (insert around 643 out of 881 characters of my SQL statement variable here) ‘ is not a valid identifier
Does anybody know anything about why this might be happening? EXECUTE @var fails, EXECUTE 'string' works…
I thought is was:
exec @mystr
–assumes the string is a procedure name and is limited to 8000 bytes
exec (@mystr)
–has the 2 gigabyte limit.