CTAS and Select Into

In both Oracle and MySQL, you can do:

create table T1 as select * from T1

This CREATE TABLE AS statement basically clones table T1 with its structure and data in T2. This can be pretty handy at times.

The equivalent of that in Sql Server is SELECT INTO. For example, you can do:

select * into T2 from T1

to achieve similar results.

2 Comments »

  1. The Ji Village News » Assign SELECT results into variables Said,

    February 7, 2007 @

    […] I mentioned here that SELECT INTO in Sql Server is functionally similar to CREATE TABLE AS in Oracle. Oracle also has SELECT INTO, but it is used for assigning query results to a variable. […]

  2. sql select into Said,

    February 2, 2008 @

    […] http://www.haidongji.com/2007/01/22/ctas-and-select-into/ The Ji Village News » CTAS and Select Into I mentioned here that SELECT INTO in Sql Server is functionally similar to CREATE TABLE AS in Oracle. Oracle also has SELECT INTO , but it is used for … […]

RSS feed for comments on this post · TrackBack URI

Leave a Comment