Wednesday, February 27, 2013

SELECT * into vs Insert into table from select list (table already exists )

hi today i would like to discuss on few useful tips
SELECT * into vs Insert into from select list

SELECT  into:
EX: SELECT * into TEMP_Backup   from Temp

First a table is created TEMP_Backup    and then data is inserted  into TEMP_Backup from Temp  so there are two steps performed

Where as if i already have a table existing with same structure and datatypes then :
Insert into TEMP_Backup  
SELECT * from Temp

This steps inserts the data to TEMP_Backup   table and here we don't have to create a table , so less overhead if it is with a big table

Both of them works with global, local temporary tables :

Thanks


No comments:

Post a Comment

https://blog.sqlauthority.com/2009/06/27/sql-server-fix-error-17892-logon-failed-for-login-due-to-trigger-execution-changed-database-context...