开发者

How to insert rows with structure from one table to another table?

开发者 https://www.devze.com 2023-03-01 09:35 出处:网络
What is the query in SQL Server to insert rows with structure from o开发者_运维问答ne table to another table?A couple ways

What is the query in SQL Server to insert rows with structure from o开发者_运维问答ne table to another table?


A couple ways

SELECT INTO

SELECT 
   field1,
   field2,
   ...
INTO Table1
FROM Table2

INSERT INTO

INSERT INTO Table1
   field1,
   field2,
   ...
SELECT
   field1,
   field2,
   ...
FROM Table2


Sounds like you want something like this:

INSERT INTO DestTable (Column1,COlumn2)
   SELECT Column1, Column2
   FROM SourceTable


Here is the documentation for the INSERT...EXECUTE statement that will allow you to do what you need.

0

精彩评论

暂无评论...
验证码 换一张
取 消