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

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...