开发者

Sql query for inserting all records from one table to another existing table

开发者 https://www.devze.com 2023-03-11 10:35 出处:网络
I am using sql server as my database engine. I need a sql query, so that I can insert all records from one table to anot开发者_运维问答her existing table. Both tables are in same DB.

I am using sql server as my database engine. I need a sql query, so that I can insert all records from one table to anot开发者_运维问答her existing table. Both tables are in same DB.

I need to use this query in my code.


 insert into destination_table ( field1, field2, field3, ... )
 select field1, field2, field3, ...
 from source_table


Assuming all of the fields match (are in the same order and of the same type)

INSERT INTO TargetTable SELECT * FROM SourceTable
0

精彩评论

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