none
Restore error: specified cast is not valid

    Question

  • I've got a database from a client (SQL 2008) and when I try and restore the database to my server, I get the following error: specified cast is not valid...

    I get the error as I browse for and select the backup file.

    Please help!!!
    Saturday, February 07, 2009 2:28 PM

Answers

  • I got it too -- and it turned out that the backup had been done from a script, and had a Password specified, but the restore was from the GUI.  Doing the restore from the command line and giving the password worked; and changing the script to back up without a password, and then restore from the GUI also worked.

     

    So the problem was that the GUI doesn't understand all the options you could have specified when you backed up the database.

    YMMV of course.


    Kip Bryan
    Monday, September 27, 2010 6:24 PM

All replies

  • Hi,

    Probably a tools issue.  You should post a question in the SQL Server Tools General Forum.  I'd move the thread for you, but you can also just do the restore via TSQL.  Like this:

    RESTORE DATABASE [MyDatabase]   
    FROM    DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008\MSSQL\Backup\AdventureWorks2008.bak'   
            WITH  FILE = 1,     MOVE N'AdventureWorks2008_Data'   
                                TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008\MSSQL\DATA\MyDatabase.mdf',    
                                MOVE N'AdventureWorks2008_Log' TO N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008\MSSQL\DATA\MyDatabase_5.ldf',    
                                NOUNLOAD,  REPLACE,  STATS = 10 

    Aaron Alton | thehobt.blogspot.com
    Saturday, February 07, 2009 10:12 PM
  • Just to add - make sure that you're using SQL 2008, or you won't be able to perform any restore at all - you can't restore down to a prior version.
    Aaron Alton | thehobt.blogspot.com
    Saturday, February 07, 2009 10:13 PM
  • And one in addition, if you are experiencing a problem in your UI, make sure you describe the way you got the error message and post the whle message in the forum (use the small icon with the error message to bring up the whole error message and the exception stack from the error message box.

    Jens K. Suessmeyer

    Sunday, February 08, 2009 10:32 AM
  • I got it too -- and it turned out that the backup had been done from a script, and had a Password specified, but the restore was from the GUI.  Doing the restore from the command line and giving the password worked; and changing the script to back up without a password, and then restore from the GUI also worked.

     

    So the problem was that the GUI doesn't understand all the options you could have specified when you backed up the database.

    YMMV of course.


    Kip Bryan
    Monday, September 27, 2010 6:24 PM