desperately need an sp to pass mutiple values for the single variable like @list
is a variable and the values I'm putting for it are '1,3,4,5,66
' and I need information from the table realated to these id's:
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)
I'm using this in my sp but I'm getting difficulty for passing this for the mutiple values.
Have you thought about using table variables to pass data to a stored procedure. Example:
Setup
Now you can insert rows into a temporary table variable of type EmpIdValuesType and pass the variable to the stored procedure:
Calling the Stored Procedure
And here are the results:
SQLFiddle