How can we handle the issue where we have lots of input parameter with varchar(max) in dynamic SQL, using execute
sp_executesql command? We have more than 20 varchar(max) input parameters to stored procedures how can I use them in a dynamic query.
Any thoughts since right now when I prepare dynamic parameter statement (nvarchar(max)), I'm explicitly truncating the size of parameters, but that will omit necessary information also.
create procedure dbo.[test]
@IP1 varchar(max),
@IP2 varchar(max)
AS
BEGIN
declare @P nvarchar(max),@Q as varchar(max)
select @Q = 'Select A.id,A.description from dbo.table1 A where A.id in ' + @IP1 + ' and A.description in ' + @IP2
select @P = N'@IP1 varchar(max),@IP2 varchar(max)'
EXECUTE sp_executesql @Q,@P,@IP1,@IP2
END
Any thoughts since right now when I prepare dynamic parameter statement (nvarchar(max)), I'm explicitly truncating the size of parameters, but that will omit necessary information also.
create procedure dbo.[test]
@IP1 varchar(max),
@IP2 varchar(max)
AS
BEGIN
declare @P nvarchar(max),@Q as varchar(max)
select @Q = 'Select A.id,A.description from dbo.table1 A where A.id in ' + @IP1 + ' and A.description in ' + @IP2
select @P = N'@IP1 varchar(max),@IP2 varchar(max)'
EXECUTE sp_executesql @Q,@P,@IP1,@IP2
END