I have large queries
so i cant use linked server in production by rules.
i pass a varchar(max)
which this has more than 8000 characters.
but sp_executesql
does not support more than 8000 characters then how can i execute my string?
I have large queries
so i cant use linked server in production by rules.
i pass a varchar(max)
which this has more than 8000 characters.
but sp_executesql
does not support more than 8000 characters then how can i execute my string?
nvarchar(max)
should work on SQL Server 2008 or later.
Does this work?:
declare @sql nvarchar(max)
set @sql = N'select' + CONVERT(NVARCHAR(MAX),REPLICATE(' ', 8000)) + ' ''Above 8000 character limit test'''
exec sp_executesql @sql
If you're using a version before that, you may need to split the query into multiple variables:
How to use SQL string variable larger than 4000 character in SQL server 2005 Stored Procedure?
Have you try to declare something like
declare @var_1 nvarchar(4000);
declare @var_2 nvarchar(4000);
.
.
.
declare @var_n nvarchar(4000);
so you do something like this
exec(@var_1 + @var_2 + ....+ @var_n)
Hope that this will help you
© 2022 - 2024 — McMap. All rights reserved.