[dba-SQLServer] SELECT INTO Versus CREATE #temp

Asger Blond ab-mi at post3.tele.dk
Fri Jul 18 08:54:37 CDT 2008


With CREATE TABLE #tempTable you can specify constraints (and thereby unique
indexes if you specify a primary key or unique constraint) in the
create-table-statement.

A table created with SELECT INTO doesn't inherit any constraints or indexes
from the source table. But you can of course build these constraints and
indexes on the destination table after it has been created.

No other difference as far as I know.

Asger
-----Oprindelig meddelelse-----
Fra: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] På vegne af Arthur
Fuller
Sendt: 18. juli 2008 15:13
Til: Discussion concerning MS SQL Server
Emne: [dba-SQLServer] SELECT INTO Versus CREATE #temp

>From a practical point of view, it would seem that these two commands are
equivalent:

SELECT * INTO #tempTable
FROM somewhere
WHERE someConditionHolds

CREATE #tempTable ( field list )
INSERT #tempTable ( field list ) SELECT * FROM somewhere WHERE
someConditionHolds

Are there performance differences or any other reason to choose one over the
other?

Arthur
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com

 









































































































































































More information about the dba-SQLServer mailing list