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.
Related
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.
I am using SQL Server 2008 R2. While restoring a database backup I'm getting an error
Specified cast is invalid
Any help will be greatly appreciated. Thanks in advance.
This was due to .BAK file corruption during FTP transfer (transfer mode is set to ASCII).
Always, remember to set FTP transfer mode to BINARY while transferring database .BAK file.
try to do this using TSql...
Use Master
Go
RESTORE DATABASE Publications
FROM DISK = 'C:\Publications_backup_2012_10_15_010004_5648316.bak'
WITH
MOVE 'Publications' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS2008R2\MSSQL\DATA\Publications.mdf',--adjust path
MOVE 'Publications_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS2008R2\MSSQL\DATA\Publications.ldf'
, REPLACE -- Add REPLACE to specify the existing database should be overwritten.
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).
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
I try to backup database using code below :
backup database RestaurantManagement to disk = 'd:\'
sqlserver always show the message below :
Msg 3201, Level 16, State 1, Line 3
Cannot open backup device 'd:\'. Operating system error 3(The system cannot find the path specified.).
Msg 3013, Level 16, State 1, Line 3
BACKUP DATABASE is terminating abnormally.
How can i code it ? help...
You need to provide the backup file name, like this:
backup database RestaurantManagement to disk = 'd:\backups\RestaurantManagement.bak'
Are you a member of the appropriate sql role? Does the account which Sql Server is running under have permissions to the path? Are you sure the media is available on the server? What I mean is, you may have a d: on your machine, but the paths you give are for the remote server.
The error you're getting indicates there's no d: drive, or no folder named backups.
I would double check all those things.