This article is reproduced in the address: http://jingyan.baidu.com/article/d5c4b52bc5c102da570dc547.html
Duplicate table structure
In the process of using SQL Server, we may need to copy the table from one database to another, and today, we will introduce you to the specific methods and steps of this operation.
1. First, open and connect to SQL Server, right-click on the source database source_db (source database name), then tap "Write table script" → "Create to" → "New Query Editor window"
2. Press "Crtl+a" in the editor generated by the 1th step to select all the contents, then right click "Copy" (or press "Crtl+c" key).
3. Create a new query, then right-paste (or CTRL + V), and change the source_db (source database name) in your code to TARGET_DB (the target database name). Then right-click Execute to execute the code.
4. Then, in the table structure of the target database, you can see the tables that have been copied.
Data content replication for tables
- Select the target database target_db, then click "Tasks" → "Import data".
- Go to the SQL Server Import and Export Wizard and follow the instructions.
- Select a data source (source database).
- Select target (target database), specify table copy, or query.
- Select source table and Source view: After you set the source and destination tables, click the Edit Mappings button and select Enable Identity insertion in the pop-up window. (Otherwise an error will occur later)
- Always click "Next" to finalize the operation.
(go) SQL Server copies the tables in the database to another database