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

后端 未结 3 511
耶瑟儿~
耶瑟儿~ 2021-01-29 02:00

What is the query in SQL Server to insert rows with structure from one table to another table?

相关标签:
3条回答
  • 2021-01-29 02:03

    Sounds like you want something like this:

    INSERT INTO DestTable (Column1,COlumn2)
       SELECT Column1, Column2
       FROM SourceTable
    
    0 讨论(0)
  • 2021-01-29 02:07

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

    0 讨论(0)
  • 2021-01-29 02:25

    A couple ways

    SELECT INTO

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

    INSERT INTO

    INSERT INTO Table1
       field1,
       field2,
       ...
    SELECT
       field1,
       field2,
       ...
    FROM Table2
    
    0 讨论(0)
提交回复
热议问题