Shadow Copy in SQL 2008 without using create command
In this article, you will see how to create a duplicate table with a new name in SQL Server.
In this article I will show you the various
methods of copying a table with a new name using a select statement in SQL
Server. It takes a lots of time to create new empty table and defining all field
names again. Various methods are explained below.
Creating Table in SQL Server
create table StudentDetails
Insert values in above table and table will
look like below image
Select all columns into new table but this way
of copying will not copy constraints and indexes. This technique will copy all
the columns of the source table (StudentDetails) to the destination table (StudentDetailsCopy).
Select only the columns we want into the new
table. Suppose we want to copy roll_num, F_Name, City columns from
StudentDetails table into the StudentDetailsCopy1 table.
To copy the structure of the source table into
another new table with new name.
Here, 1=2 will prevent the data from being copied from
to the StudentDetailCopy2