Tuesday 23 October 2018

Select Insert into table from another table using sql server

/////////// Sql Query


------------------------- Insert table to table all data
SELECT * INTO newTableName FROM oldTableName WHERE Condition;

------------------------- Insert table to table selected columns
SELECT s.CustomerName, s.OrderID INTO CustomersOrderBackup2017 FROM Customers s LEFT JOIN Orders o ON o.CustomerID = s.CustomerID

------------------------- Insert table to table selected columns with conditions
SELECT s.CustomerName, s.OrderID INTO CustomersOrderBackup2017 FROM Customers s LEFT JOIN Orders o ON o.CustomerID = s.CustomerID WHERE Condition;


No comments:

Post a Comment

Excel Sort values in ascending order using function TEXTJOIN

 Excel ::  Text ::  1,3,5,2,9,5,11 Result :: 1,2,3,5,5,9,11 Formula ::     TEXTJOIN ( ",",1,SORT(MID(SUBSTITUTE( A1 ,","...