如何在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/[^]