Monday, 21 March 2016

Difference between SELECT INTO and INSERT INTO SELECT SQL Statement

SELECT INTO and INSERT INTO SELECT are the two sql statements which are quite useful as other statements.


The major difference is,

The INSERT INTO SELECT statement copies data from one table and inserts it into an existing table.

         INSERT INTO Table2 SELECT * FROM Table1;


And,

The SELECT INTO statement copies data from one table and inserts it into a new table (i.e. creates a new object). 

           SELECT ColumnNames INTO FROM Tablename;



So, if you want to copy the data from one table to another existing table then use INSERT INTO SELECT and if you want to create a backup copy or new object of table with same structure and records then use SELECT INTO statement.


 Hope so this might be helpful.




How To Pass An Array As A Parameter While Calling an ASP.NET Web API C#

Please visit my C# Corner Blog for this, where I have provided better efforts to make this concept more understandable - www.c-sharpcorner....