Hi,
I have a dynamic SQL stored procedure that looks like:
==========================================
ALTER PROCEDURE sp_Analys
@Parameter1 as nvarchar (4000),
@Parameter2 as nvarchar (50)
AS
DECLARE @sql nvarchar(4000)
SET @sql ='
select Field1,Field2,Field3
from Table1
where Field1 in ('+char(39)+@Parameter1+char(39)+')
and Field2='+char(39)+@Parameter2+char(39)+''
exec sp_executeSQL @SQL
=========================================
When I try to run the procedure with both parameters:
execute sp_Analys '47740'',''47999'',''47993' 'TEST99'
...I get: "Incorrect syntax near 'TEST99'"
If I remove one parameter from the stored procedure then there's no problem.
Is there a way to run both parameters?
Kent J.
I have a dynamic SQL stored procedure that looks like:
==========================================
ALTER PROCEDURE sp_Analys
@Parameter1 as nvarchar (4000),
@Parameter2 as nvarchar (50)
AS
DECLARE @sql nvarchar(4000)
SET @sql ='
select Field1,Field2,Field3
from Table1
where Field1 in ('+char(39)+@Parameter1+char(39)+')
and Field2='+char(39)+@Parameter2+char(39)+''
exec sp_executeSQL @SQL
=========================================
When I try to run the procedure with both parameters:
execute sp_Analys '47740'',''47999'',''47993' 'TEST99'
...I get: "Incorrect syntax near 'TEST99'"
If I remove one parameter from the stored procedure then there's no problem.
Is there a way to run both parameters?
Kent J.