Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
Belongs on stackoverflow –  gbn May 14 '10 at 16:22
    
agreed it there a process to migrate this to my account on SO? –  Christopher Kelly May 17 '10 at 12:42

1 Answer 1

up vote 2 down vote accepted

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.