Description:
In this example we explain that how to use SQL string variable larger than 4000 character in SQL Server Stored procedure because we all know that SQL will not execute Query parameter contains more than 4000 character so to overcome this problem we have to use the while loop and assign the string in a variable.
There are
many questions are raised from user like nvarchar max after 4000 character not working.
Or trouble printing out long varchar max string.so below is the query that will
help you when you SQL Query size more than 4000 character.
print len(@Query);
declare
@i int = 1
while
Exists(Select(Substring(@Query,@i,4000))) and (@i < LEN(@Query))
begin
print
Substring(@Query,@i,4000)
set
@i = @i+4000
end
print
@i;
0 comments:
Post a Comment