Inline Query Too Large For Varchar(MAX)

  • My SQL Server 2005 inline query is over 8K in length. The variable I'm using to store the query text is defined as Varchar(MAX). I have tried splitting up the inline query into 2 chunks of text, each one going into a separate Varchar(MAX) variable. However, when I PRINT or EXEC by concatenating the 2 variables, it cuts off once again at 8K. I'm using this statement:

    PRINT @variable1 + @variable2

    Any ideas how I can get beyond the 8K limit? My google search has some people stating that the Varchar(MAX) limit is 2GB, but that isn't my experience.

  • After experimenting for awhile, I determined that only the PRINT statement (PRINT @Variable1 + @Variable2) truncates to 8K. The EXEC statement does not. Problem solved.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply