且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Microsoft SQL Server从选择查询中插入

更新时间:2022-04-24 22:00:00

您可以将以下语法用于插入

You can use the following syntax for inserts

INSERT INTO dbo.Destination (Col1, Col2, Col3)
SELECT Col1, Col2, Col3
FROM dbo.Source

如果您的表具有与目标相同的列或结果集,这些结果与目标具有相同的列,则不必在INSERT中指定列.

If you had tables with the same columns or a result set that had the same columns as your destination, you don't have to specify columns in the INSERT.

INSERT INTO dbo.Destination
SELECT *
FROM dbo.Source

这两个都基于已经创建的Destination表.这些SELECT * INTO dbo.Destination FROM dbo.Source

Both of these are predicated on your Destination table already being created. These are NOT the same as SELECT * INTO dbo.Destination FROM dbo.Source