迫切需要一个 sp 来为单个变量传递多个值,例如@list
一个变量,我为它输入的值是 ' 1,3,4,5,66
',我需要从表中与这些 id 相关的信息:
SELECT T.C.value('.', 'NVARCHAR(100)') AS [id]
INTO #tblPersons
FROM (SELECT CAST ('<Name>' + REPLACE(@empid, ',', '</Name><Name>') + '</Name>' AS XML) AS [Names]) AS A
cross APPLY Names.nodes('/Name') as T(C)
我在我的 sp 中使用它,但我很难将它传递给多个值。