65.9K
CodeProject is changing. Read more.
Home

Copy paste complete Table SQL Server

starIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

1.00/5 (1 vote)

Dec 16, 2011

CPOL
viewsIcon

16892

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:
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
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.