[沒有蠢問題] 快速複製 MS SQL 資料表

  • 59
  • 0
  • 2022-04-05

快速複製 MS SQL 資料表

SELECT *
INTO newtable [IN externaldb]
FROM oldtable
WHERE condition;

SELECT column1, column2, column3, ...
INTO newtable [IN externaldb]
FROM oldtable
WHERE condition;

SELECT Customers.CustomerName, Orders.OrderID
INTO CustomersOrderBackup2017
FROM Customers
LEFT JOIN Orders ON Customers.CustomerID = Orders.CustomerID;

//複製資料表結構
SELECT * INTO new_table_name FROM oldtable
 WHERE 0=1;

參考文章
SELECT INTO 敘述句
SQL SELECT INTO Statement

如果內容有誤請多鞭策謝謝