Print Max query in sql

Clash Royale CLAN TAG#URR8PPPPrint Max query in sql
How to print dynamic query that contains more than 8000 chars.
Declare @sql varchar(max)
set @Qry='....(more than 8000 char)'
Print (@Qry)
Any help?
Thanks.
varchar(max) can store up to 2gb ....
– JeffUK
7 mins ago
1 Answer
1
Just do it, varchar(max) can hold upto 2gb. E.g.
declare @test varchar(max);
declare @loop int = 1;
set @test= 'select ''1000000000000000000000000000000000000000000''';
while @loop < 1001
begin
set @test = @test + ',''1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000''';
set @loop = @loop + 1;
end;
select len(@test);
exec(@test);
len(@test) is around 100,000 characters, exec works as expected.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Print (CAST(@Qry as TEXT))
– Tapakah Ua
10 mins ago