Skip to content

Latest commit

 

History

History
66 lines (43 loc) · 2.75 KB

duplicate-tables.md

File metadata and controls

66 lines (43 loc) · 2.75 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic helpviewer_keywords monikerRange
Duplicate tables without the row data.
Create a duplicate copy of a table, without the row data.
WilliamDAssafMSFT
wiassaf
10/21/2021
sql
table-view-index
conceptual
copying tables
tables [SQL Server], duplicating
duplicating tables
duplicating table structures
table copying [SQL Server]
>=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current

Duplicate tables

[!INCLUDE sqlserver2016-asdb-asdbmi-asa-pdw]

You can duplicate an existing table in [!INCLUDEssnoversion] by using [!INCLUDEssManStudioFull] or [!INCLUDEtsql] by creating a new table and then copying column information from an existing table.

These steps described duplicate only the structure of a table, not the row data.

Permissions

Requires CREATE TABLE permission in the destination database.

Use SQL Server Management Studio

To duplicate a table

  1. Make sure you are connected to the database in which you want to create the table and that the database is selected in Object Explorer.

  2. In Object Explorer, right-click Tables and select New Table.

  3. In Object Explorer right-click the table you want to copy and select Design.

  4. Select the columns in the existing table and, from the Edit menu, select Copy.

  5. Switch back to the new table and select the first row.

  6. From the Edit menu, select Paste.

  7. From the File menu, select Save table name.

  8. In the Choose Name dialog box, type a name for the new table. Select OK.

Use Transact-SQL

To duplicate a table in Query Editor

  1. Make sure you are connected to the database in which you want to create the table and that the database is selected in Object Explorer.

  2. Right-click the table you wish to duplicate, point to Script Table as, then point to CREATE to, and then select New Query Editor Window.

  3. Change the name of the table.

  4. Remove any columns that are not needed in the new table.

  5. Select Execute to create the new table.

Next steps