Sunday, February 19, 2012

Create Duplicate of table ?

I want to create a copy of a table with a new name, what is the best way to
do this. I did notice I could copy a table, but there is no paste !?!SELECT * INTO CopyOfMyTable FROM MyTable WHERE 1=2
1=2 means that only table structure will be copied without data. The
downside is that if you create a new table that way
SQL Server will not transfer PK and FK as well as Indexes and Constraints
created on original table
An Identity property SQL Server does transfer.
"p" <p@.p.com> wrote in message
news:OKMLB2k%23FHA.532@.TK2MSFTNGP15.phx.gbl...
>I want to create a copy of a table with a new name, what is the best way to
>do this. I did notice I could copy a table, but there is no paste !?!
>|||SELECT * INTO Newtablename
FROm OldTableName
HTH, jens Suessmeyer.|||You guys are realy great for coming back so quick with an answer. Thanks to
both of you for the replies.
"Jens" <Jens@.sqlserver2005.de> wrote in message
news:1133865309.548099.228200@.g43g2000cwa.googlegroups.com...
> SELECT * INTO Newtablename
> FROm OldTableName
> HTH, jens Suessmeyer.
>

No comments:

Post a Comment