如何在SQL Server数据库单个表中插入多个记录. [英] How to insert multiple records in sql server database single table.

查看:75
本文介绍了如何在SQL Server数据库单个表中插入多个记录.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用此语句在远程服务器上安装多个记录

I am trying to install multiple records on the remote server using this statement

Insert into XYZ
(
a,
b
)
Values
('x','y'),
('x','y'),
('x','y'),
('x','y')



但是它不插入但是如果我插入单个值然后它的工作,我错了吗?请帮忙.



but its not inserting however if i insert single value then its working, where i am wrong? please help.

推荐答案

您应该在单独的插入命令中编写它们.
You should write them in separate insert commands.
Insert into XYZ(a,b) Values ('x','y')
Insert into XYZ(a,b) Values ('x','y')
Insert into XYZ(a,b) Values ('x','y')
Insert into XYZ(a,b) Values ('x','y')




如果源数据位于表中,请使用insert into TARGETTABLE(FIELD1, FIELD2, ... ) select FIELD1, FIELD2, ... from SOURCETABLE 命令.


希望对您有所帮助.




And if source data is located in a table use insert into TARGETTABLE(FIELD1, FIELD2, ... ) select FIELD1, FIELD2, ... from SOURCETABLE command .


Hope it helps.


尝试以下链接:

http://msdn.microsoft.com/en-us/library/ms174335.aspx [ ^ ]
http ://blog.sqlauthority.com/2007/06/08/sql-server-insert-multiple-records-using-one-insert-statement-use-of-union-all/ [ ^ ]
Try the following link :

http://msdn.microsoft.com/en-us/library/ms174335.aspx[^]
http://blog.sqlauthority.com/2007/06/08/sql-server-insert-multiple-records-using-one-insert-statement-use-of-union-all/[^]


这篇关于如何在SQL Server数据库单个表中插入多个记录.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆