How to Create a Duplicate Table in SQL
How to Create a Duplicate Table in SQL
Need to create a new SQL table based on the structure of an existing table? This wikiHow article will teach you how to duplicate an existing SQL table in SQL Server Management Studio and Transact SQL.
Steps

Using SQL Server Management Studio

Connect to the database you want to modify. If you haven't already, you'll also need to select your database in Object Explorer.

Right-click Tables and select New Table. You'll only see this if you're in Object Explorer.

Right-click the table you want to copy and select Design. As soon as you click this, you'll be asked to create the table's parameters.

Select the columns in the original table and select Copy. The Copy button is inside the Edit toolbar menu item.

Navigate to where you want the new table to be and select the first row.

Paste the copied data. From the Edit menu, select Paste to enter the data from your clipboard to your selected cells.

Save your file. Once the table is pasted into a new table, you can go to the File menu and click Save. Your file manager will open so you can name the file and save it to a specific location.

Using Transact-SQL

Connect to the database you want to modify. If you haven't already, you'll also need to select your database in Object Explorer.

Right-click the table you want to copy and select Script Table as. Another menu will expand.

Select CREATE to. Another menu will expand.

Select New Query Editor Window.

Enter a name for the copied table. This should be something different than the original. If there are any columns you don't need in the duplicated version, remove them now.

Select Execute. This creates a new table from the original table.

What's your reaction?

Comments

https://hapka.info/assets/images/user-avatar-s.jpg

0 comment

Write the first comment for this!