I’ve been searching through all the examples and answers of how to pass any array (say like List<int>, List<string> or even array[int or string], to sql server,till i found this link, below is how I applied it to my project:
–The following code is going to get an Array as Parameter and insert the values of that –array into another table
Create Procedure Proc1
@INFO_ARRAY ARRAY nvarchar(max) //this is the array your going to pass from C# code
AS
declare @xml xml
set @xml = N'<root><r>’ + replace(@INFO_ARRAY,’,’,'</r><r>’) + ‘</r></root>’
Insert into Products
select
t.value(‘.’,’varchar(max)’)
from @xml.nodes(‘//root/r’) as a(t)
END