How to upgrade a database from localdb/v11.0 to localdb/mssqllocaldb without errors?

Visual Studio says I need to upgrade the database file. So I to try to attach the database file again. But whenever I attach, I get the following error-

So how can I upgrade it? Thanks. 


Note: I have moved the database from one computer to the other. 


August 27th, 2015 8:11am

Hi Bhupinder,

According to my knowledge, the above error could occur when the database is corrupt. If you have backup of the database, you can follow the steps in this similar blog to restore the database to localdb/mssqllocaldb  instance.

However, if you dont have the backup, execute the following scripts to restore database.         

CREATE DATABASE [MATERIALSDB]

  ON (FILENAME = 'c:\wherever\ MATERIALSDB.mdf')

  FOR ATTACH_REBUILD_LOG;

If that fails, perform the following process and check if it works.

on your localdb/mssqllocaldb instance, create a database with a data file of the exact same size

shutdown SQL Server

rename the new database's mdf file, and paste the old one in its place

bring up the server and let the database attempt to be recovered and then go into suspect mode

put the database into emergency mode with ALTER DATABASE MATERIALSDB SET EMERGENCY

run DBCC CHECKDB (MATERIALSDB, REPAIR_ALLOW_DATA_LOSS); which will rebuild the log and run full repair

There is a similar thread for your reference.
http://dba.stackexchange.com/questions/42762/how-to-attach-an-mdf-file-that-was-not-properly-detached/42807#42807

Thanks,
Lydia

Free Windows Admin Tool Kit Click here and download it now
September 1st, 2015 2:44am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics