使用一条插入语句插入多条记录 [英] Insert Multiple Records Using One Insert Statement
本文介绍了使用一条插入语句插入多条记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用一个存储过程插入多行.
我目前这样的插入语句
Hi, I want to insert multiple rows using one stored procedure.
my current insert statements like that
squery = "insert into pricing values(''I'', getdate(), ''msg 0 goes here'');"
squery += "insert into pricing values(''B'', getdate(), ''msg 1 goes here'');"
squery += "insert into pricing values(''C'', getdate(), ''msg 2 goes here'');"
sqlcommand.CommandText = squery
Try
sqlcommand.ExecuteNonQuery()
现在,我尝试切换到存储过程,如果我仅输入一条记录,它将起作用,但是我无法插入多个记录
now i tried to switch to stored procedure it work if i am entering one record only but i can''t get it to insert multiple
squery =InsertSP ''C'', ''MSG'';
squery +=InsertSP ''V'', ''MSG'';
它给了我错误,并告诉我语法上有错误.
it gives me error and tells me there is error in the syntax
推荐答案
如果只有一种方法可以搜索Code Project来找到合适的文章...
这是一种方法:如何将多个记录传递到存储过程 [ ^ ].
If only there was a way to search Code Project to find suitable articles...
Here is one way: How to pass multiple records to a Stored Procedure[^].
这篇关于使用一条插入语句插入多条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文