SQL Server copies the tables in the database to another database

Source: Internet
Author: User

In the process of using SQL Server, we may need to copy the table from one database to another, and today I'll show you how and how to do this. It may be a simple thing for most people, but it is better to record it than to write a good memory. Hope can help the students who need ...

Copy table structure:

First step: 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".

Step two: 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).

Step three: 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.

Fourth step: Then, you can see the copied table in the table structure of the target database.

Data content replication for tables:

First step: Select the target database target_db, then click "Tasks" → "Import data".

Step two: Go to the SQL Server Import and Export Wizard and follow the instructions.

Step three: Select the data source (source database).

Fourth step: Select target (target database), specify table copy or query.

Fifth step: Select source table and Source view: After setting the source and target tables, click the Edit Map button and select "Enable identity insertion" in the pop-up window. (Otherwise an error will occur later)

Sixth step: Always click "Next" to finalize the operation.

SQL Server copies the tables in the database to another database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.