Can't restore compatible database back to SQL Server 2008 R2 - sql-server-2008-r2

We have client with SQL Server 2008 R2 and database created on same server. So the compatibility is set as 10.
We're running mostly on SQL 2012. In event we backup database from 2008 and restore in 2012, make some data changes (no schema change), and then back it up again, we can't restore back to 2008.
It would prompt "No backupset selected to be restored". But seems that the compatibility is retained. Opening Management Studio as Administrator doesn't work either.
This method use to work fine with one previous client, but they have upgraded to 2012 now.

You are having a compatibility issue.
Just set compatibility mode and try to restore database again.
ALTER DATABASE Databasename SET COMPATIBILITY_LEVEL = 80
You have to set COMPATIBILITY_LEVEL as per your database is
suppose if backup database COMPATIBILITY_LEVEL is 90 than set COMPATIBILITY_LEVEL = 90.
Now restore database and if database restored successfully than again set previous COMPATIBILITY_LEVEL to the level it was before restore.

Related

migrate existing biztalk server database from sql server 2008 R2 to sql server 2012

we are planning to move biztalk database from one place to another as well as upgrade the sql server.
the initial database is in sql server 2008 R2 and target is sql server 2012.
but the thing is that we have to set up database on another system,
i tried to search it on msdn but they are providing reference to upgrade from 2005 to 2008 , or moving database from one server to another.
do you think that will work in my case !!
i found this article.http://msdn.microsoft.com/en-us/library/ee378547%28v=bts.10%29.aspx
relating to upgrading as well as moving..
but this is quite older one.
how can i upgrade as well as move biztalk database from sql server 2008 R2 to sql server 2012 on a different system (side by side upgrade).
do i have to follow same steps as upgrading a normal database from sql server 2008R2 to sql server 2012 or some other one ??
As long as the SQL Server edition (2012 in your case) you are migrating to is supported by your BizTalk Server edition, you can follow the procedure to move BizTalk databases.
You can check the version compatibility here.

Database MSDB can not be opened

I have got this problem in local instance of SQL Server 2008 R2 on my machine. There are several databases on this instance. But I am not able to see any of them from the object explorer.
I am able to query my databases from the new query window. But not able to see any of them.
Whenever I try to explore the databases I get this error :
Database 'msdb' cannot be opened. It has been marked SUSPECT by recovery. See the SQL Server errorlog for more information. (Microsoft SQL Server, Error: 926).
I have tried
Refreshing the connection
Reconnecting the connection
Restarting the service Sql Server (MSSQLSERVER).
Restarting the SQL Server Management Studio
Restarting my machine
I have also tried combinations of above, but nothing works.
My operating system is Windows 7 Ultimate (64 bit).
SQL Server Management Studio Version is 10.50.2500.0.
I found my answer in this link.
EDIT : Including both the solutions from link because of possible Linkrot in future.
Login with sa account, for both the solutions.
Solution 1
Open new query window
EXEC sp_resetstatus 'DB_Name'; (Explanation :sp_resetstatus turns off the suspect flag on a database. This procedure updates the mode and status columns of the named database in sys.databases. Also note that only logins having sysadmin privileges can perform this.)
ALTER DATABASE DB_Name SET EMERGENCY; (Explanation : Once the database is set to EMERGENCY mode it becomes a READ_ONLY copy and only members of sysadmin fixed server roles have privileges to access it.)
DBCC checkdb('DB_Name'); (Explanation : Check the integrity among all the objects.)
ALTER DATABASE DB_Name SET SINGLE_USER WITH ROLLBACK IMMEDIATE; (Explanation : Set the database to single user mode.)
DBCC CheckDB ('DB_Name', REPAIR_ALLOW_DATA_LOSS); (Explanation : Repair the errors)
ALTER DATABASE DB_Name SET MULTI_USER; (Explanation : Set the database to multi user mode, so that it can now be accessed by others.)
Solution 2
In Object Explorer --> The opened connection item --> rightclick --> Stop
Open Control Panel --> Administrative Tools --> Services
Select Sql Server (MSSQLSERVER) item from services --> rightclick --> Stop
Open C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA
Move MSDBData.mdf & MSDBlog.ldf to any other place
Then Copy this Files Again from new place and put it in older place
C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA
In opened connection in object Explorer --> rightclick --> Start
Then Refresh DataBase.
Then you can Detach the MSDB File
The 2nd solution worked for me.
Note : I had to get "msdb" database mdf and ldf files from another working machine to get it working.
What instantly fixed my issue was to replace existing MSDBData.mdf & MSDBlog.ldf files
in C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA. I got these 2 files copied from another working machine, Stopped the SQL service running in my machine, removed the above existing 2 files from their location and added the new 2 copied. Once I restarted the service , issues has been fixed.
Try this
Set the database into single user mode:
Alter database dbname set single_user
Now set the database into emergency mode:
Alter database dbname set emergency
Repair missing log file or corrupted log file with data loss.
DBCC CHECKDB ('dbname', REAPIR_ALLOW_DATA_LOSS)
Now set the db in multi user mode;
Alter database dbname set multi_user
You may loss the data by using this command. It also depends on client's approval. To avoid this you may use some other dedicated software ( As Mentioned here ) to recover from suspect mode.

How to restore SQL Server 2008 R2 backup to a LocalDb 2012

I have a backup of a database (.bak) created ​​in SQL Server 2008 R2.
To test some features, like to import this backup to LocalDB (2012).
When I click on Restore and select the database the following error occurs:
Property MasterDBLogPath is not available for Information 'Microsoft.SqlServer.Management.Smo.Information'. This property may not exist for this object, or may not be retrievable due to insufficient access rights. (Microsoft.SqlServer.Smo)
You need to add the following 3 registry keys (run/regedit):
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11E.LOCALDB\MSSQLServer\DefaultData,
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11E.LOCALDB\MSSQLServer\DefaultLog,
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11E.LOCALDB\MSSQLServer\BackupDirectory
With an existing folder name as value (where you have write access), e.g. "C:\Databases".
Please have a look at the excellent walkthrough under http://www.roelvanlisdonk.nl/?p=2896 (which is where I have copied the answer from).

How to restore SQL SERVER MANAGEMENT STUDIO DATABASE to PC Server to SQLEXPRESS Server?

I am using SQL SERVER MANAGEMENT STUDIO 2008 R2. I have used my pc's name(For example, MY-PC) as a server name to make databases. Now how can I get the database I created in my pc's named server, when I select .\sqlexpress as a server.
The error it shows when I tried to restore in .\sqlexpress from .bak file:
Restore failed for Server 'MY-PC\SQLEXPRESS'. (Microsoft.SqlServer.SmoExtended)
Additional Information:
System.Data.SqlClient.SqlError: The database was backed up on a server running version 10.50.1600. That version is incompatible with this server, which is running version 10.00.2531. Either restore the database on a server that supports the backup, or use a backup that is compatible with this server. (Microsoft.SqlServer.Smo)
You can't restore the database in the above scenario - as per the error, the backup was taken on a SQL Server 2008R2 instance, and you are trying to restore it on a SQL Server 2008 instance - backup files are not backwards compatible.
You can see this from the error message:
10.50.1600 is SQL Server 2008 R2 RTM
10.00.2531 is SQL Server 2008 Service Pack 1
See the following Microsoft article for details on SQL Server version numbers:
http://support.microsoft.com/kb/321185

Error: Specified cast is not valid. (SqlManagerUI)

I have a backup from database in SQL Server 2008 R2.
When I want to restore this backup to SQL Server, I get this error:
"Error: Specified cast is not valid. (SqlManagerUI)"
How to I resolve this error?
Thanks.
This would also happen when you are trying to restore a newer version backup in a older SQL database. For example when you try to restore a DB backup that is created in 2012 with 110 compatibility and you are trying to restore it in 2008 R2.
There are some funnies restoring old databases into SQL 2008 via the guy; have you tried doing it via TSQL ?
Use Master
Go
RESTORE DATABASE YourDB
FROM DISK = 'C:\YourBackUpFile.bak'
WITH MOVE 'YourMDFLogicalName' TO 'D:\Data\YourMDFFile.mdf',--check and adjust path
MOVE 'YourLDFLogicalName' TO 'D:\Data\YourLDFFile.ldf'
Sometimes it happens because of the version change like store 2012 db on 2008, so how to check it?
RESTORE VERIFYONLY FROM DISK = N'd:\yourbackup.bak'
if it gives error like:
Msg 3241, Level 16, State 13, Line 2
The media family on device 'd:\alibaba.bak' is incorrectly formed. SQL Server cannot process this media family.
Msg 3013, Level 16, State 1, Line 2
VERIFY DATABASE is terminating abnormally.
Check it further:
RESTORE HEADERONLY FROM DISK = N'd:\yourbackup.bak'
BackupName is "* INCOMPLETE *",
Position is "1",
other fields are "NULL".
Means either your backup is corrupt or taken from newer version.
I had a similar error "Specified cast is not valid" restoring from SQL Server 2012 to SQL Server 2008 R2
First I got the MDF and LDF Names:
RESTORE FILELISTONLY
FROM DISK = N'C:\Users\dell laptop\DotNetSandBox\DBBackups\Davincis3.bak'
GO
Second I restored with a MOVE using those names returned:
RESTORE DATABASE Davincis3
FROM DISK = 'C:\Users\dell laptop\DotNetSandBox\DBBackups\Davincis3.bak'
WITH
MOVE 'JQueryExampleDb' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\Davincis3.mdf',
MOVE 'JQueryExampleDB_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\Davincis3.ldf',
REPLACE
GO
I have no clue as to the name "JQueryExampleDb", but this worked for me.
Nevertheless, backups (and databases) are not backwards compatible with older versions.