The problem of attaching a higher version to a lower version of the database is that

Source: Internet
Author: User

The problem of attaching a higher version to a lower version of the database is that

My computer room charging system was knocked out on my laptop. After I knocked it out, I copied the database and put it on the desktop. I was going to use the desktop to check and accept the system. When I attach a database, the system prompts "the database 'charge _ sys 'version is 661 and cannot be opened. This server supports both version 655 and earlier. The downgrade path is not supported ."

This is because my current SQL is 2008R2, and the database on the computer in the data center is 2008 (of course, this will happen if it is earlier than 2008 ). Currently, I only know two solutions:

1. Upgrade the SQL of the earlier version to the later version. However, this is not only a waste of time, but also very troublesome.

2. Generate a lower script for the database to be used on a high-version computer. Then, create a new database with the same name in the earlier version of the database and execute the script generated by the later version of the computer. The procedure is as follows:

1. Right-click the database for which the script is to be generated, and select Task-generate script


2. Go to the script generation page-next step


3. Select a specific database object -- table -- select all -- next step

 

4. Select advanced (note that the file name contains the script generation path)

·

5. On the Advanced page, select the version of the script you want to write in "write scripts for server version" -- OK -- next

6. Select next


7. Wait until the script is saved and released.

8. Create a database with the same name on a computer of a lower version, and double-click the generated script file to execute it.

Open the database you just created and check whether the table exists in the database. But the content in the table does not exist and needs to be added again. Now, prepare for acceptance.


How can I attach a database of a higher version to a database of a lower version?

1. Open manger studio of SQL SERVER 2008
-- Open "Object Resource Manager" and connect to the instance
-- Right-click the database to go to 2005
-- Task
-- Generate scripts
-- In the "select database" in the "script wizard", make sure that the selected database is to be transferred to 2005.
-- Select "write scripts for all objects in the selected Database" 5
-- In the next "select script options", set "Write database creation script" to "True", find "write script for Server version", and select "SQL Server 2005"
-- Set other options as needed
-- Finally, save the script to A. SQL script file.

2. Create the target database in 2005
In the query analyzer (or 2008 manger studio opens the script file), connect to SQL Server 2005 and execute the script generated above to create a new database.

3. import data from 2008 to 2005
Open the Enterprise Manager of SQL Server 2005
-- Right-click the database to import data
-- Task
-- Import data
-- In the "Select data source" step of the "SQL Server Import and Export wizard", select the database to be exported.
-- In the "Select data source" step, connect to 2005 and select the source database
-- In "select source table and source View", select all tables
-- Final Completion
Export data from the SQL2008 database to another database. If the database has an auto-incrementing primary key, an error will be reported during the export.

Solution: import the database to "select source table and Source view"-> click "Edit ing" next to the corresponding table-> select "enable ID column insertion"-> Import.

Why can't I append an mdf file of a later SQL server database?

Yes. 662 is the database version number after SQL Server 2008 SP2 and SQL Server 2008 before SP2.
The database version is 655, while 661 is the database version of SQL Server 2008 R2. The version of SQL Server 2008 R2 is higher than that of SQL Server 2008, it is common sense that the database files of version 661 cannot be appended to SQL Server 655 that supports version 2008. This is because Microsoft has added the 15 k Number of partitions to SQL Server 2008 SP2, and SQL Server 2008 R2 has been released before SQL Server R2, because SQL Server 2008 R2 RTM does not support 15 K partitions, if the version number of SQL Server 2008 is 655, a data file with 15 K partitions attached to SQL Server may appear.
In 2008 R2 RTM, this must not be attached. To solve this problem, Microsoft breaks the general rule. In SQL Server 2008 SP2, the database version is changed to 662, the database version of SQL Server 2008 R2 RTM is lower than that of SQL Server 2008 SP2, so it cannot be attached, avoiding the trouble, however, the version number has changed the side effects for the function of a 15 K partition, just like the landlord.
The root cause of the problem.
To put it bluntly, you attach the database of SQL Server 2008 R2 to SQL Server 2008, which is definitely not feasible. Upgrade your current database instance to SQL Server 2008 R2 and install the latest SP patch before attaching it. You can either append the chat database to a database instance of SQL Server 2008 R2, generate a script file of SQL Server 2008, and deploy it in SQL Server 2008 SP2.

As for a friend in front of me who said that using the backup method would certainly not work if I understood what I said before.

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.