Detach/Attach invalid SQL Server file

  • I recieved a SQL Server backup file from one of my clients and restored it to my local SQL Server.  I think the backup was good.  I ran a DBCC CHECKDB and it came back with no errors.  All of the data appears to be present and uncorrupted.  I then detached the DB and attempted to attach it.  It appears as if SQL Server cannot read the header inforamation as I get an error stating that it is not a valid SQL Server database file. 

    BTW...When attempting to attach, I tripple checked that I was browsing to the MDF file.  Any ideas?

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • Before Detach, have you executed any queries to see for sure database was

    up and running. Why I am saying this is 'I think the backup was good' 

    mean you  are not 100 % sure about that.

    Second point is if backup was good, why you have detached the db and again attach that. Attach and detach db files always have risk associted with it, if you miss or mess something it's gone, and that's why this is not recommeded way. This is just FYI.

    Try attaching only db file with following command

    EXEC sp_attach_single_file_db @dbname = 'pubs',

         @physname = 'C:\MSSQL\Data\pubs.mdf'

    Kindest Regards,

    Sameer Raval [Sql Server DBA]
    Geico Insurance
    RavalSameer@hotmail.com

  • Yes, all of the data was present.  I ran select queries.  I also ran DBCC CHECKDB, which displays record counts for each table after it completes. 

    sp_attach_single_file_db gives the following error:

    "The FOR ATTACH option requires that at least the primary file be specified."

     

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • Check Orignial File Name and Current File(s) Location

    and Also what database you are creating in Attach as 'xxxx' and specify database owne 'sa' or backup user name

     

     

    Suresh

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply