Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 create table query

Author  Topic 

surenhr
Starting Member

5 Posts

Posted - 2007-08-22 : 15:28:22
Hi..
i logged in to query editor of sql server 2005

create table test as (select * from dummy);
or
create table test as select * from dummy;

when i executed this command it shows an error:-> invalid syntax near as.

any comments!!!!!!!!!!!!!!

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-22 : 15:29:14
select *
into test
from dummy
where 1 = 0

Read Books Online.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

surenhr
Starting Member

5 Posts

Posted - 2007-08-22 : 15:33:51
will it create a new table test and populate it with all the contents of dummy ?????
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-08-22 : 15:35:47
quote:
Originally posted by surenhr

will it create a new table test and populate it with all the contents of dummy ?????



why dont you try it and see for youself?

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-22 : 15:47:33
quote:
Originally posted by surenhr

will it create a new table test and populate it with all the contents of dummy ?????

If you also want the contents, remove the WHERE part.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

surenhr
Starting Member

5 Posts

Posted - 2007-08-22 : 15:57:21
thank u very much Sir ...:-)
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-22 : 15:58:35
Please remember that indexes, triggers, constraints are not transferred.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-08-24 : 05:36:05
Another approach

select Top 0 *
into test
from dummy



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -