Results 1 to 12 of 12
  1. #1
    Join Date
    Jan 2004
    Posts
    6

    Unanswered: restoring from .bak file

    Tried restoring a database from .bak file through Enterprise Manager and also by usng the following code :

    RESTORE DATABASE DBB
    FROM DISK = 'c:\DBA.BAK'
    WITH
    REPLACE,
    RECOVERY,
    MOVE 'ap0data' TO 'c:\mssql\data\apm_data.mdf',
    MOVE 'ap0Log' TO 'c:\mssql\data\apm_log.ldf'

    But, I get an error :
    Server: Msg 3156, Level 16, State 2, Line 1
    The file 'd:\mssql7\data\apm.mdf' cannot be used by RESTORE. Consider using the WITH MOVE option to identify a valid location for the file.

    I have got the two filenames i.e."ap0data" and "ap0log" by using the command "restore fileslistonly from disk = c:\dba.bak".


    Can anyone help me to do the things rigtly ?

  2. #2
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    This should work !!!
    Code:
    RESTORE DATABASE DBB
    FROM DISK = 'c:\DBA.BAK'
    WITH MOVE 'ap0data' TO 'c:\mssql\data\apm_data.mdf',
    MOVE 'ap0Log' TO 'c:\mssql\data\apm_log.ldf'
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

  3. #3
    Join Date
    Jan 2004
    Posts
    6

    restoring of .bak

    Thanks for your help.

    I tried the code, but got error:

    Server: Msg 3154, Level 16, State 1, Line 1
    The backup set holds a backup of a database other than the existing 'apm' database.

    I don't have the original database. I have just created a blank database and I am trying to restore.

  4. #4
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    RESTORE FILELISTONLY
    FROM 'c:\DBA.BAK'

    RESTORE FILELISTONLY
    FROM 'c:\DBA.BAK' WITH FILE = 2


    Run these two and get back with the results
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

  5. #5
    Join Date
    Jan 2004
    Posts
    6
    RESTORE FILELISTONLY
    FROM 'c:\DBA.BAK'




    RESTORE FILELISTONLY
    FROM 'c:\DBA.BAK' WITH FILE = 2

    Server: Msg 4038, Level 16, State 1, Line 1
    Cannot find file ID 2 on device 'c:\windows\desktop\cmpbk.BAK'.

  6. #6
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    Try this :
    Code:
    RESTORE DATABASE DBB FROM  DISK = N'c:\DBA.BAK' WITH  FILE = 1,  
    RECOVERY ,  REPLACE ,  
    MOVE N'ap0data' TO N'c:\mssql\data\apm_data.mdf',  
    MOVE N'ap0Log' TO N'c:\mssql\data\apm_log.ldf'
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

  7. #7
    Join Date
    Jan 2004
    Posts
    6
    Tried :

    Server: Msg 3156, Level 16, State 2, Line 1
    The file 'c:\mssql\data\apm_data.mdf' cannot be used by RESTORE. Consider using the WITH MOVE option to identify a valid location for the file.

  8. #8
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    sp_helpdb dbb

    ???
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

  9. #9
    Join Date
    Jan 2004
    Posts
    6
    name = apm
    db_size = 2.00mb
    owner = sa
    bdid = 8
    status = select into/bulkocopy, trun. log on chkpt



    name = apm_data
    fileid = 1
    filename = c:\mssql7\data\apm_data.mdf
    filegroup = primary
    maxsize = unlimited
    growth = 10%
    usage = data only


    name = apm_log
    fileid = 2
    filename = c:\mssql7\data\apm_log.ldf
    filegroup = null
    maxsize = unlimited
    growth = 10%
    usage = log only

  10. #10
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    am clutching at straws now

    RESTORE DATABASE TestDB FROM DISK = N'c:\DBA.BAK' WITH
    MOVE N'ap0data' TO N'c:\mssql\data\apb1_data1.mdf',
    MOVE N'ap0Log' TO N'c:\mssql\data\apb1_log1.ldf'



    i mean try restoring to a completely new database ... let the restore statements create the db
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

  11. #11
    Join Date
    Jan 2004
    Posts
    6

    Thumbs up

    Hey, It worked.

    Thank you very much, Sir

  12. #12
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    now you can use the sp_renamedb command to change it to the name you want.
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •