none
I Get an Error When attempting to Restore .bak file to an Empty Database RRS feed

  • Question

  • I get an Error when I attempt to restore a .bak file to an Empty database. Error below

    The file 'D:\SQL_Server_Database\WSS_Content_SP.mdf' cannot be overwritten. It is being used by database 'WSS_Content'.

    Thank you,

    Mike W


    SharePoint Engineer - Mike

    Monday, October 28, 2019 6:39 PM

All replies

  • Is there any application or session connecting the database? Try to set the "Restrict Access" to SINGLE_USER and then restore the database and finally put MULTI_USER back.

    A Fan of SSIS, SSRS and SSAS

    Monday, October 28, 2019 6:59 PM
  • Hi Mike Williams,

    Does the original database ("WSS_Content") you want to restore already exist?

    The reason for the restore failure may be that these original locations are still used by the original database ("WSS_Content ").

    You could use the WITH MOVE clause to specify a new location for all files in the database.

    For more details, please refer to RESTORE Statements.

    In addition, here is a similar thread might be helpful to you.

    Hope this could help you.

    Best Regards,

    Amelia Gu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, October 29, 2019 2:25 AM
  • I get an Error when I attempt to restore a .bak file to an Empty database

    Databases are never empty. If you want to restore a backup over an existing database the you have to use the restore option REPLACE.

    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    Tuesday, October 29, 2019 7:04 AM
  • I solved it I think. Would this fix the issue? Do you think the solution will affect the source database?

    https://serverfault.com/questions/244665/mdf-file-cannot-be-overwritten-when-restoring-a-database-in-sql-server/916032ou think this solves my issue and will it affect the source database??

    SharePoint Engineer - Mike






    Tuesday, October 29, 2019 2:01 PM
  • Hi Mike Williams,

    >> Would this fix the issue? Do you think the solution will affect the source database?

    Yes, the solution from the link can fix the issue.

    And the solution will affect the source database. Because with the REPLACE option, restore allows you to overwrite an existing database with whatever database is in the backup set, even if the specified database name differs from the database name recorded in the backup set. This can result in accidentally overwriting a database by a different database. For more details, please refer to REPLACE Option Impact.

    Hope this could help you.

    Best Regards,

    Amelia Gu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, October 30, 2019 7:12 AM