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
 General SQL Server Forums
 New to SQL Server Programming
 Create table

Author  Topic 

endir
Starting Member

4 Posts

Posted - 2005-09-29 : 11:08:09
I need to create a new table by coping all an existing one. this without specifing the column to the new table. just to copy from the existing table.
is any way to do that???
how can i do that?????
thanks

ryanston
Microsoft SQL Server Product Team

89 Posts

Posted - 2005-09-29 : 11:21:43
quote:
Originally posted by endir

I need to create a new table by coping all an existing one. this without specifing the column to the new table. just to copy from the existing table.
is any way to do that???
how can i do that?????
thanks





select * into new_table from old_table


Thanks,

----------------------
Ryan Stonecipher
Developer, Microsoft SQL Server Storage Engine, DBCC
(Legalese: This posting is provided "AS IS" with no warranties, and confers no rights.)
Go to Top of Page

endir
Starting Member

4 Posts

Posted - 2005-09-29 : 11:41:37
Thanks for the reply.
I knew that i can do a select statement but i wanted more to know if i can use a CREATE TABLE statement with an expression in this case a select...into. i tryed and i cant find a way so that to work.
thanks
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-30 : 00:35:18
Note that new_table wont have the indices and contraints that old_table has

Madhivanan

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

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2005-09-30 : 23:36:27
And the answer to your question is no. You can do what Ryan showed you, use DTS, etc.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page
   

- Advertisement -