can i pass a List into a SqlCommand as a paramter?
DELETE FROM MyTable WHERE Key IN @MyParam
command.Parameters.AddValue("MyParam",MyList);
i realize i could just loop over the list but i was looking for a cleaner solution.
csvsqlsql servertsql
can i pass a List into a SqlCommand as a paramter?
DELETE FROM MyTable WHERE Key IN @MyParam
command.Parameters.AddValue("MyParam",MyList);
i realize i could just loop over the list but i was looking for a cleaner solution.
Best Answer
No, you can't in the current form
There are several options using UDFs or XML or dynamic SQL to pass in lists.
The most comprehensive article on how to do this is "Arrays and Lists in SQL Server 2005 and Beyond" by Erland Sommarskog