-1

I have a database backup file I need to restore in SQL Server 2008. I get an error

Specified cast is not valid. (SqlManagerUI)

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    That usually indicates incompatible versions of SQL Server, like the backup is from 2012 but you're attempting to restore into 2008. – Lloyd Jul 03 '15 at 09:32
  • 1
    On the error dialog, you can see the incompatible sql versions. Something like `SQL Server 10.50.1600` – jmc Jul 03 '15 at 09:39
  • What is the *exact* error message? Press Ctrl+C on the dialog box to copy the entire message text. What are the database versions involved? – Panagiotis Kanavos Jul 03 '15 at 09:43
  • There is at least one duplicate question, eg [SQL Server database restore error: specified cast is not valid. (SqlManagerUI)](http://stackoverflow.com/questions/13604720/sql-server-database-restore-error-specified-cast-is-not-valid-sqlmanagerui). Check the steps described there. The UI often returns invalid messages. Try generating the restore script (click the Script button) and check the actual error message generated when you execute the `RESTORE` statement – Panagiotis Kanavos Jul 03 '15 at 09:46

2 Answers2

0

Try this first and see if the backup is healthy:

DO
RESTORE FILELISTONLY FROM DISK = N'YOURFILE.bak'

then we can take it from there

Shane_Yo
  • 770
  • 8
  • 24
  • This should be a comment – Panagiotis Kanavos Jul 03 '15 at 09:43
  • Msg 3241, Level 16, State 13, Line 1 The media family on device 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\Backup\mygtl.bak' is incorrectly formed. SQL Server cannot process this media family. Msg 3013, Level 16, State 1, Line 1 RESTORE FILELIST is terminating abnormally. – Manish Solanki Jul 03 '15 at 10:09
  • RESTORE FILELISTONLY FROM DISK = N'YOURFILE.bak' – Manish Solanki Jul 03 '15 at 10:09
  • I was try this but this was given me like...Msg 3241, Level 16, State 13, Line 1 The media family on device 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\Backup\mygtl.bak' is incorrectly formed. SQL Server cannot process this media family. Msg 3013, Level 16, State 1, Line 1 RESTORE FILELIST is terminating abnormally. – Manish Solanki Jul 03 '15 at 10:10
  • 2
    @ManishSolanki: the `MSSQL10_50` in the `.bak` file name seems to indicate a backup from a SQL Server **2008 R2** version - this is **incompatible** with the **2008** version, you **cannot** restore a newer `.bak` file (from SQL Server **2008 R2** - v10.50) onto an older instance of SQL Server, e.g. **2008** (v10.00) – marc_s Jul 03 '15 at 10:21
0

Please check the Sql server version of the database from where you have backed up the version of database must be same or upper .Only then you can restore the database backup

Chander .k
  • 541
  • 4
  • 12
  • If you read the question, you 'll see that the OP did that and got an error message – Panagiotis Kanavos Jul 03 '15 at 09:41
  • Hello sir, I have one project that was created using c# and Microsoft SQL Server 2008 R2. now I want to add some modules into this project also I have backup file for this database even I can`t restore database in same version of Microsoft SQL Server 2008 R2.It will give error like Specified cast is not valid. (SqlManagerUI) I am not sure what I am doing wrong. I would appreciate help in this regarding – Manish Solanki Jul 07 '15 at 06:55
  • Please check [this](http://stackoverflow.com/questions/13604720/sql-server-database-restore-error-specified-cast-is-not-valid-sqlmanagerui) post – Chander .k Jul 07 '15 at 07:03
  • If you are still getting this error and Just try to do it by generating Sql of all the database. – Chander .k Jul 07 '15 at 07:07