-
May 3rd, 2012, 12:19 PM
#1
[RESOLVED] create table syntax - mssql 2008 r2
Is this syntax no longer valid?
Code:
CREATE TABLE MYTABLE AS SELECT * FROM ANOTHER_TABLE;
i am pretty certain it works in oracle8i and upwards. It doesn't work in MSSQL.
The syntax that works in MSSQL is
Code:
SELECT * INTO MYTABLE from ANOTHER_TABLE
is there one more way to do this in SQL Server 2008?
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
May 3rd, 2012, 12:24 PM
#2
Re: create table syntax - mssql 2008 r2
That is ORACLE syntax and it's mixing DDL and DML syntax (CREATE is DDL and SELECT is DML) - yuk.
MS SQL has the INTO keyword - which you found already - and from what I know is the only way to make a table from a select.
-
May 3rd, 2012, 12:29 PM
#3
Re: [RESOLVED] create table syntax - mssql 2008 r2
Interesting thing about standards is that they often say that you have to implement a feature (in this case, creating a table based on the results from a select statement) but not how (a good example of this is HTML... and why something looks one way in IE but differently in FF or Chrome, etc)... Oracle and MS went down different roads in this case. the "S" in SQL stands for "Structured" ... not "Standard"... people tend to forget this.
-tg
-
May 3rd, 2012, 12:36 PM
#4
Re: [RESOLVED] create table syntax - mssql 2008 r2
tg,
one reason is that none of the vendors (microsoft / oracle / ibm included) have certified beyond the ANSI-92 entry level standard. As a matter of fact, NIST doesn't even certify anymore.
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
May 3rd, 2012, 12:42 PM
#5
Re: [RESOLVED] create table syntax - mssql 2008 r2
I feel that CREATE is a single keyword statement - takes an OBJECT name - and lots of possible parameters/arguments in ()'s.
SELECT is a "free text" parsed-like command string...
I personally like INTO - and the more recently added OUTPUT - keywords that you can use with SELECT and UPDATE and DELETE statements...
Makes more sense to me...
btw - I started doing SQL back in the Sybase mainframe days - so I'm kind of slanted towards the Sybase/MS syntax.
Dealing with dates in Oracle - like today and TODATE and formatting - wow - so other-worldly (imo).
-
May 3rd, 2012, 01:06 PM
#6
Re: [RESOLVED] create table syntax - mssql 2008 r2
I have been doing Oracle since 2002. Prior to that I worked exclusively with SQL Server and MS Access.
I now find the pl-sql syntax more natural than sql.
There was a brief period, when I was a card-carrying member of the I-hATE-Oracle club, but over a period of time I have changed my views.
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|