Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / SQL

Copy paste complete Table SQL Server

1.00/5 (1 vote)
16 Dec 2011CPOL 16.9K  
Using a very simple query we can make replica of existing table along with full data and datatypes
There is a pretty nice method available to transfer data from one table to another

Transfer data from existing table to new table:
SQL
select * into table2 from table1

Copy all data from table1 into table2 (it creates new table2 no need to write create statement)

It will create new table2 and transfer all data from table1 to table2

Transfer data from existing table1 to existing table2:

If you want to transfer data from one table to existing table2 then use
SQL
Insert into vt_FE_Role1
Select [Role] from vt_FE_Role

Do not include primary key column if it is set as identity. Otherwise you can use it.
You must take care of RDBMS if exists.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)