I'm using the varchar(MAX) value for text but as开发者_StackOverflow社区 I'm building up the huge SQL it cuts the ending off.
Is there any way I can create a Dynamic Declare statement that I can then join together with others when executing the sql?
e.g. something like:
DECLARE @sSQLLeft + Convertvarchar(4),@index) varchar(MAX)
varchar(max)
is up to about 2GB are you sure it cuts the ending off or is it just when you print it it only displays the first few hundred characters?
To View long text in SSMS without it getting truncated you can use this trick
SELECT @dynsql AS [processing-instruction(x)] FOR XML PATH('')
DECLARE @query VARCHAR(MAX)
DECLARE @query2 VARCHAR(MAX)
-- Do wahtever
EXEC (@query + @query2)
EDIT:
Martin Smith is quite right. It is possible that your query cuts in print. One of the reasons of this cut is NULL value in variable or in column which concatenates with your query and make rest of the query NULL.
精彩评论