This blog is to describe how to copy and paste one table or its record to another table in SQL Server.
In SQL Server we can do following things:
- We can copy the whole structure and data of one table to another table.
- We can copy only the structure of one table without coping the data.
- We can copy only particular data from one table to another table.
Before showing each function i would like to show my table
Now i want to create a similar table and copy all records from here to my new table.
so here my query will be-
Here "mytable1" is my new table.This query will copy all the records with the structure of the table.
Now i need to copy the structure of a table without data.
For this the where conditon always contains false statement. It will give the following result.
Now i want to copy particular data from an existing table which have the structure same as my table.
Here "mytable5" is my existing table which structure is same as "Mytable".