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 a copt of existing table

Author  Topic 

yalgaar
Starting Member

43 Posts

Posted - 2006-02-25 : 13:37:04
How can I create a new table with a new name which is an exact copy of an existing table with:

1) All rows

2) no rows, only the structure of the table.

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-02-25 : 13:38:16
1. select * into NewTableName from OldTableName
2. select * into NewTableName from OldTableName where 1=0

Go with the flow & have fun! Else fight the flow
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-02-25 : 13:57:01
(Note that this will create the structure, in general, but not any secondary indexes, triggers, and other possibly "clutter" that the original table might have had)

Its a pretty cool way to get stuff into a new table though ...

K
Go to Top of Page
   

- Advertisement -