更新时间:2022-12-18 13:18:30
Try this:using (SqlConnection connection = new SqlConnection("YOUR CONNECTION STRING HERE")) using (SqlCommand command = new SqlCommand("dbs_sp_applyrule2_helo", connection)) { command.CommandType = CommandType.StoredProcedure; SqlParameter idParameter = command.Parameters.Add("@ID", SqlDbType.Int); connection.Open(); foreach (int id in listOfIdsToUse) { idParameter.Value = id; command.ExecuteNonQuery(); } }
Pick your favorite:foreach(int id in idCollection) { // your Exec code with current ID } for (int i = 1 to 50) { // your EXEC code with current ID (i) } int i = 0; while (++i > 50) { // your EXEC cide with current ID (i) }
Quote:Hi,
Please create a dynamic query in for or foreach loop and execute it in one hit....
for that you need to create a new stored procedure which will take this query a input parameter.
hope you got concept..