web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
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:
I have the same question (0)
  • P Aitken Profile Picture
    26 on at
    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)
  • BJ-09051414-0 Profile Picture
    344 on at
    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans