Database - How to move database files?

Top  Previous  Next


(Source: AutoCount Forum, 11 Jan.2009)


How to move my database from current folder to a new folder ?


By default, all created database files (e.g. AED_NewCompany_Data.mdf and AED_NewCompany_Log.ldf) are located at C:\AutoCount Data. These files are then attached to SQL Database Server and subsequently to AutoCount Accounting.


Before moving database files from its current path (C:\AutoCount Data) to another folder/location/drive, you must ‘detach’ the database from SQL Server, by using Microsoft SQL Server Express Management Studio.



Install SQL Server Express management Studio


1. Check at your SQL Database Server, if you have installed Microsoft SQL Server Express Management Studio, go to step 3. Otherwise proceed to step 2.


2. Install Microsoft SQL Server Express Management Studio onto your server. The installer can be found on AutoCount CDROM, look up at  \SupportFiles\SQLExpress Support Files\SQLServer2005_SSMSEE.msi.



Detach Database From SQL Server


3. Make sure all AutoCount users have logged out the program.

4. Start Microsoft SQL Server Express Management Studio, login to the server e.g. (local)\A2006 using Windows Authentication. (You must be the Administrator of this PC)

5. In the Object Explorer windows, click on the + sign before Databases. Identify the database name that you wish to detach, for example: AED_MOBILE. Right click on the database name and select Tasks > Detach.  A Detach Database windows will be displayed. Click on OK. The database will be detached from this SQL Database Engine.



            HowTo-Move Database Files01



Move Database To New Folder


6. (Do not close SQL Server Express Management Studio, we will be back in a short while.) Open Windows Explorer and move the database files (from C:\AutoCount Data) to a new location within the same machine. Note: You must move both data file (*.mdf) and log file (*.ldf) together.



Attach Database back to SQL Server


7. Back to SQL Server Express Management Studio, right click on Databases node and select Attach. Click on Add button and browse to select database from the new path, then click on OK.


            HowTo-Move Database Files02



Note: As long as the newly attached databases are the same as before they were detached, there is nothing needed to be done in AutoCount Accounting and users can work on it immediately.



** In case the Database Server (the PC) is to be formatted, then there is no need to detach databases one by one (it is however always advisable to backup databases); what you need to do is just stop the SQL service, copy the folder of AutoCount Data to a removable drive/or other PC, then go ahead and format the PC. After SQL Server is reinstalled, you will need to copy AutoCount Data folder back to the machine, perform attach database (one by one) in SQL Server, install  AutoCount Accounting and attach the account book using Attach Account Book, or Synchronize All Account Books With Database Server, or Open Account Book Control File.







Send feedback about this topic to AutoCount.

© 2013 Auto Count Sdn Bhd - Peter Tan. All rights reserved.