Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

Does anyone know how to restore a dynamics company from a .mdf file?

(1) ShareShare
ReportReport
Posted on by 26
I don't have a good backup and the server crashed!  I do have a .mdf and .ldf from the server that crashed but they weren't detachted before the server crashed so I can't just attach it.   Is there a way I can restore the company database from the .mdf file???  
 
IF anyone can think of a way OR any alternative I'm open.  They've already been down for a week so this is really critical at this point!!
 
Thank in advance!
Categories:
  • BJ-09051414-0 Profile Picture
    BJ-09051414-0 268 on at
    Does anyone know how to restore a dynamics company from a .mdf file?
    Hello,
     
    Based on the error message it appears another process is locking the file.
     
    CREATE FILE encountered operating system error 32(The process cannot access the file because it is being used by another process.) while attempting to open or create the physical file 'D:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\EMC.mdf'. (Framework Microsoft SqlClient Data Provider)
     
    I would try restarting the SQL Server to make sure nothing is locked or stuck and try again. 
     
    If this does not work, I would suggest posting on the SQL Forum as this is really a SQL issue and not a GP issue.
     
    I hope this helps!
     
    Thank you!
     
    Brandon,
    Enavate Functional Consultant.
  • P Aitken Profile Picture
    P Aitken 26 on at
    Does anyone know how to restore a dynamics company from a .mdf file?
    This is the error message I get when trying to "attach" the .mdf    Hopefully this might help 
     
     
    Details:
    ===================================
    Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)
    ------------------------------
    For help, click: https://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&LinkId=20476
    ------------------------------
    Program Location:
       at Microsoft.SqlServer.Management.Sdk.Sfc.Enumerator.Process(Object connectionInfo, Request request)
       at Microsoft.SqlServer.Management.SqlManagerUI.AttachDatabaseData.PrimaryFile.GetOriginalDatabaseName(String primaryFilePath)
       at Microsoft.SqlServer.Management.SqlManagerUI.AttachDatabaseData.PrimaryFile.PopulatePrimaryFileData(String primaryFilePath, Boolean isXIPath)
       at Microsoft.SqlServer.Management.SqlManagerUI.AttachDatabaseData.PrimaryFile..ctor(SqlManagementUserControl parent, CDataContainer dc, String fullPath, String databaseOwner, ServerConnection connectionInfo, Boolean isXIPath)
       at Microsoft.SqlServer.Management.SqlManagerUI.AttachDatabase.AddPrimaryFile(String fullPath, String fileName, Boolean isXIPath)
       at Microsoft.SqlServer.Management.SqlManagerUI.AttachDatabase.buttonBrowse_Click(Object sender, EventArgs e)
    ===================================
    An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
    ------------------------------
    Program Location:
       at Microsoft.SqlServer.Management.Common.ServerConnection.GetExecuteReader(SqlCommand command)
       at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteReader(String sqlCommand, SqlCommand& command)
       at Microsoft.SqlServer.Management.Smo.ExecuteSql.GetDataReader(String query, SqlCommand& command)
       at Microsoft.SqlServer.Management.Smo.DataProvider.SetConnectionAndQuery(ExecuteSql execSql, String query)
       at Microsoft.SqlServer.Management.Smo.ExecuteSql.GetDataProvider(StringCollection query, Object con, StatementBuilder sb, RetriveMode rm)
       at Microsoft.SqlServer.Management.Smo.SqlObjectBase.FillData(ResultType resultType, StringCollection sql, Object connectionInfo, StatementBuilder sb)
       at Microsoft.SqlServer.Management.Smo.SqlObjectBase.FillDataWithUseFailure(SqlEnumResult sqlresult, ResultType resultType)
       at Microsoft.SqlServer.Management.Smo.SqlObjectBase.BuildResult(EnumResult result)
       at Microsoft.SqlServer.Management.Smo.PrimaryFile.GetData(EnumResult erParent)
       at Microsoft.SqlServer.Management.Sdk.Sfc.Environment.GetData()
       at Microsoft.SqlServer.Management.Sdk.Sfc.Environment.GetData(Request req, Object ci)
       at Microsoft.SqlServer.Management.Sdk.Sfc.Enumerator.GetData(Object connectionInfo, Request request)
       at Microsoft.SqlServer.Management.Sdk.Sfc.Enumerator.Process(Object connectionInfo, Request request)
    ===================================
    CREATE FILE encountered operating system error 32(The process cannot access the file because it is being used by another process.) while attempting to open or create the physical file 'D:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\DATA\EMC.mdf'. (Framework Microsoft SqlClient Data Provider)
    ------------------------------
    For help, click: https://docs.microsoft.com/sql/relational-databases/errors-events/mssqlserver-5123-database-engine-error
    ------------------------------
    Server Name: EANDMCOMMCS
    Error Number: 5123
    Severity: 16
    State: 20
    Line Number: 1

    ------------------------------
    Program Location:
       at Microsoft.SqlServer.Management.Common.ConnectionManager.ExecuteTSql(ExecuteTSqlAction action, Object execObject, DataSet fillDataSet, Boolean catchException)
       at Microsoft.SqlServer.Management.Common.ServerConnection.GetExecuteReader(SqlCommand command)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,996 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,853 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans