Duplicate tables
Applies to: SQL Server 2016 (13.x) and later Azure SQL Database Azure SQL Managed Instance Azure Synapse Analytics Analytics Platform System (PDW)
You can duplicate an existing table in SQL Server by using SQL Server Management Studio or Transact-SQL 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
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.
In Object Explorer, right-click Tables and select New Table.
In Object Explorer right-click the table you want to copy and select Design.
Select the columns in the existing table and, from the Edit menu, select Copy.
Switch back to the new table and select the first row.
From the Edit menu, select Paste.
From the File menu, select Save table name.
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
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.
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.
Change the name of the table.
Remove any columns that are not needed in the new table.
Select Execute to create the new table.
Next steps
Phản hồi
https://aka.ms/ContentUserFeedback.
Sắp ra mắt: Trong năm 2024, chúng tôi sẽ dần gỡ bỏ Sự cố với GitHub dưới dạng cơ chế phản hồi cho nội dung và thay thế bằng hệ thống phản hồi mới. Để biết thêm thông tin, hãy xem:Gửi và xem ý kiến phản hồi dành cho