我有这个存储过程发送参数到存储过程在SQL Server 2008中
Usp_temp
@temp nvarchar(50)
Where city in (@temp)
,我尝试发送的参数NUM这样
Usp_temp '1,3,5'
是什么做的正确方法?
我有这个存储过程发送参数到存储过程在SQL Server 2008中
Usp_temp
@temp nvarchar(50)
Where city in (@temp)
,我尝试发送的参数NUM这样
Usp_temp '1,3,5'
是什么做的正确方法?
尝试看看这篇文章: http://www.codeproject.com/KB/database/SPParameters.aspx
你应该能够用这个例子从文章来解决问题:
DECLARE @IDs varchar(100)
SELECT @IDs = '429,446,552,1001, 332 , 471'
--Any IDs as an example
SELECT Convert(Int, NullIf(SubString(',' + @IDs + ',' , ID , CharIndex(',' , ',' + @IDs + ',' , ID) - ID) , '')) AS IDList
FROM tblToolsStringParserCounter
WHERE ID <= Len(',' + @IDs + ',') AND SubString(',' + @IDs + ',' , ID - 1, 1) = ','
AND CharIndex(',' , ',' + @IDs + ',' , ID) - ID > 0
看一看这些文章:Arrays and Lists in SQL Server 2005 and Beyond ,Arrays and Lists in SQL Server 2008。
他们讨论的可能是将值列表传递给SP的所有理智方法。