Sunday, October 19, 2014

How to duplicate a TABLE using Microsoft SQL Server Mangement?

We can easily duplicate a TABLE using Microsoft SQL Server Management Studio by using the following two line of codes:

SELECT * INTO NewTable
FROM OldTable                                 

Note:

  • change NewTable to your desired table name
  • change OldTable to your current table name
  • the above SQL will copy only the basic table structure and all the data of that table. The SQL will NOT copy any of the constraints. To do this, you need to script those out and change the names in those scripts

No comments:

Post a Comment