Moving a CIMPLICITY SQL Database using Detach/Attach Proficy HMI/SCADA CIMPLICITY Introduction The purpose of this document is to outline the minimal steps required to move a Microsoft SQL Server Express database from one SQL installation (computer) to another. Sometimes this is necessary because of the need to maintain and continue the existing database tables and data. One such need can arise if an existing computer running CIMPLICITY and the SQL database is going to be replaced by a new computer. Prerequisites The steps outlined in this document only apply to Microsoft SQL Server Express 2005 and above. The screen shots in this document are taken from SQL Server Express 2008 Management Studio. As this is specific to SQL Server 2005/2008, this means that the CIMPLICITY installation must be version 7.0 or higher. Note: This document does not apply to the Microsoft Desktop Engine (MSDE). MSDE is the SQL database used in older versions of CIMPLICITY (below version 7.0). The source and destination computers in this process must all have SQL Server Management Studio installed. By default, the SQL Server Management Studio does not install with CIMPLICITY. The install for this is located in the Extras sub folder on the CIMPLICITY 7.0 and above installation disc. Alternatively, it is possible to obtain the SQL Server Management Studio installation software from Microsoft web site directly. The SQL Server Management Studio provides the access necessary to view and work on the databases. On the destination (new) computer, the SQL server must be installed and the versions must be the same as those used in the source computer. If the version of SQL Server on the source computer is not the same as the version on the destination (new) computer you may have to perform additional steps. The CIMPLICITY project must be stopped first prior to any work been done on the SQL database. Stopping the SQL services is not necessary; only that the CIMPLICITY project must be stopped.
Database Migration Steps 1) Stop all CIMPLICITY projects running on the computer 2) Launch the SQL Server Management Studio from: Start All Programs Microsoft SQL Server 2005 (or 2008) 3) Log in to the SQL database to access the CIMPLICITY database. An Administrator account will be required (Either SQL login or Windows login is fine). Figure 1: The SQL Management Studio Login Dialog
4) Navigate to the Database folder and open it. Locate the CIMPLICITY database. Note: The CIMPLICITY database is the default CIMPLICITY database but your setup maybe different. It is only necessary that you identify the actual database you are working with and that you intend to move. In this example, the database used is called CIMPLICITY. Important: Do NOT make any changes to or move default System Databases. Detach the Database: a) In the SQL Management Studio Locate the "CIMPLICITY" database folder, b) Right the CIMPLICITY database and choose "Tasks->Detach from the right click menu. c) Click OK. At this point the database will be detached (unmounted) by SQL and no longer listed in SQL Express Management Studio). Figure 2: Detaching the Database via the Right Click Menu.
Figure 3: Once the CIMPLICITY Database is Detached, it Will No Longer be Listed in the SQL Express Management Studio
d) Copy the primary data and transaction files from this (existing computer) to the new computer. For the CIMPLICITY database these files will be called CIMPLICITY.mdf and CIMPLICITY.ldf. Note: These files will be located in the SQL Server installation /data folder. For example the following would be a possible SQL Server installation folder: C:\Programs Files\GE Fanuc\Proficy CIMPLICITY\MSSQL.1\MSSQL\Data If the new computer already has an existing (empty) CIMPLICITY database, it will need to be first detached (as in the steps outlined above), then removed, before the new copy is reattached. Attach the Database: After the copy of the data (.mdf) and transaction log files (*.ldf) to the new computer it is now time to attach the database using the SQL Server Express Management Studio. Figure 4: Example SQL Server installation location data folder contents.
To attach the copied database to this new system, do the following: a) On the destination machine start the SQL Server Express Management Studio and login with an Administrator account. b) Right click on the Databases folder and select Attach... from the right click menu. A new attach database dialog will open. Figure 5: The right-click menu for attaching the databases.
Figure 6: The attach database dialog. c) Click on the Add button. d) In the Add dialog, browse and locate the CIMPLICITY.mdf file that was copied to this destination computer. e) Select the CIMPLICITY.mdf and file and click OK.
Figure 7: The attach Database dialog.
Figure 8: The attach Database dialog after selecting the database.
f) Click OK on the Attach Database dialog. g) After this the database CIMPLICITY should show as accessible in the SQL Server Express Management Studio. It is now fully accessible and usable in its given location. Figure 9: The CIMPLICITY database re-attached inside SQL Server Express Management Studio.