Databases in SQL Server are ported to each other.

Source: Internet
Author: User

In the last few days to tidy up the BS template material, Brother Siang let us on the server to publish a few sites, I am responsible for the Yonghe cashier system backstage release, this system has a feature, in the login page before loading to the database to query information, if there is no information in the database, the whole program can not run at all, Without knowing the requirements and business logic of the system, we had to get the database to the server and publish it. This is the problem, the database on the server SQLServer2008 R2 version, my is SQLServer2012, separate database can not be backward compatible, and my data in the database to transplant the past, this swollen wood do?

On the Internet to find some information about the database migration data, here I would like to introduce about.

1. Back up the database and restore it on the target machine

Backing up the database in BAK format, this method is available across the same version of SQL Server, but after my SQLServer2012 backup has been restored to SQLServer2008 R2, it won't work.

2. Detach the attached database.

This method is to separate the target database in the SQL Server Object Explorer and then copy it to another machine, and then in the attached database, this method will be ok between the same version, or the version is not very large, but for my problem, still does not work.

3. Generate SQL Script

This is the last method of my experiment, which is to generate the SQL script (with the data in the database) and then execute it on the target machine, because you can choose the script for Server version option when generating the SQL script. This makes up for the data incompatibility issues that are caused by the different versions of SQL Server, which are detailed steps below.

Right-click the database to generate the script-task-generate script, as shown below






in this you can edit the build path and then click Advanced Options.


In this select the version of the exported SQL script, as well as the schemas and data to be exported.

Then follow the prompts, Next, next ... It was a success.





Click Done, that's it, OK, finally, the exported SQL script executes on the target machine, builds the library first, then builds the table to insert the data, finally is so successful. In fact, there are many ways to export data, I just introduced one of them, SQL Server is really powerful, we also need to explore each of its functions.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Databases in SQL Server are ported to each other.

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.