-
Copy table structure
First, open and connect to Sql Server, right-click on the source database Source_db (source database name), and then click "Script Table As" → "CREATE To" → "New Query Editor Window".
-
In the editor generated in step 1, press the "crtl+a" key combination to select all the content, then right-click and "copy" (or press the "crtl+c" key).
-
Create a new query, then right-click and "Paste" (or ctrl+v); as shown in the figure, change the Source_db (source database name) in the code to target_db (target database name). Then right-click "Execute" to execute the code.
-
Then, you can see the copied table in the table structure of the target database.
END
Copy the data content of the table
-
Select the target database target_db, and then click "Task" → "Import Data".
-
Enter the "SQL Server Import and Export Wizard" and operate according to the prompt steps.
-
Select the data source (source database).
-
Select the target (target database), specify table replication or query.
-
Select the source table and source view: After setting the source table and target table, click the "Edit Mapping" button, and check "Enable Identity Insertion" in the pop-up window. (otherwise there will be an error later)
-
Keep clicking "Next" until you finish the operation.
-