Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

"CTAS" in SQL Server Expand / Collapse
Author
Message
Posted Wednesday, March 12, 2008 11:55 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, February 2, 2010 8:29 PM
Points: 3, Visits: 31
Hi, There is something called "CTAS" create table as in Oracle and was wondering if there was anything like that in SQL 2000.

I am a newbie to SQL.

In Oracle you can do the following..

create table my.test
as
select * from your.test;

also

insert into my.test
select * from your.test;

Your help in much appreciated...all this excercise is to put some load a DB server, by CTAS'ng a big table.

Thanks in Advance
Ramki
Post #468306
Posted Wednesday, March 12, 2008 12:26 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Saturday, August 30, 2014 5:24 PM
Points: 7,139, Visits: 15,191
Look at using Select ... INTO


Example:

Select *
INTO MyNewTable
from MyOldTable

Uses whatever it derives from the query to make a table.


----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
Post #468319
Posted Wednesday, March 12, 2008 4:53 PM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Thursday, June 5, 2014 10:54 AM
Points: 9,902, Visits: 9,480
Matt Miller (3/12/2008)
Look at using Select ... INTO


Example:

Select *
INTO MyNewTable
from MyOldTable

Uses whatever it derives from the query to make a table.

And if you want to "Create As" like this but without any data:
Select *
INTO MyNewTable
from MyOldTable
Where 0=1



-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung
Proactive Performance Solutions, Inc.
"Performance is our middle name."
Post #468429
Posted Wednesday, March 12, 2008 5:59 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, February 2, 2010 8:29 PM
Points: 3, Visits: 31
Thankyou!
Post #468447
Posted Wednesday, March 12, 2008 8:38 PM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Wednesday, April 2, 2014 2:01 PM
Points: 659, Visits: 6,104
There are 2 differences between SELECT INTO and INSERT INTO...

SELECT INTO only works for if the inserted table does not exist. INSERT INTO works if the inserted table already exists.


DAB
Post #468470
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse