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

Author  Topic 

juicyapple
Posting Yak Master

176 Posts

Posted - 2008-02-03 : 22:05:41
how to create table by copy the existing table structure but not data content....

tprupsis
Yak Posting Veteran

88 Posts

Posted - 2008-02-03 : 22:22:35
In SQL Server Management Studio, right click on the table, choose script > create > new query window. Now you have the code to create the table. You can run that code in your new database or rename the table to recreate it in the same db.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-03 : 23:06:28
SELECT TOP 0 * INTO NewTable FROM CurrentTable
Go to Top of Page

juicyapple
Posting Yak Master

176 Posts

Posted - 2008-02-12 : 01:38:19
[code] SELECT TOP 0 * INTO NewTable FROM CurrentTable[/code]

I have tried on it, it won't copy the column index. What are the bad impact to create table in this way?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-02-12 : 01:40:12
quote:
Originally posted by juicyapple

 SELECT TOP 0 * INTO NewTable FROM CurrentTable


I have tried on it, it won't copy the column index. What are the bad impact to create table in this way?



Yes. That will only create the table. Use the method as describe by tprupsis. it will generate a table creation script plus any other indexes, pk etc depending on you selection


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -