直接传字符串string strWhere = "9,67,9";sql = sql + where id in '(' + strWhere + ')'
写个存储过程 在里面 拼sql语句 exec('select * from test where id in ('+@charstr+')')
string sql = "select * from A " string ss = "9,67,29"; ss = ss.Trim().Trim(','); if (ss == string.Empty) { return; } else { sql = sql + " where id in (" + ss+ ")"; //............ }
exec('select * from test where id in ('+@charstr+')')
string sql = "select * from A "
string ss = "9,67,29";
ss = ss.Trim().Trim(',');
if (ss == string.Empty)
{
return;
}
else
{
sql = sql + " where id in (" + ss+ ")";
//............
}