SQL将List <int>作为SqlCommandparameter passing

我可以将List传递给SqlCommand作为参数吗?

从MyTable中删除WHERE Key IN @MyParam

command.Parameters.AddValue( “MyParam”,MYLIST);

我意识到我可以只是在列表中循环,但我正在寻找一个更干净的解决scheme。

不,你不能以目前的forms

有几种使用UDF或XML或dynamicSQL来传递列表的选项。

关于如何做到这一点的最全面的文章是由Erland Sommarskog撰写的“SQL Server 2005及更高版本中的数组和列表”