### Upgrade ApplicationModules database

PME Segment Edition Note: The default path for any of the PME Segment Editions is different and needs to be changed to reflect this.

1. Navigate to the `...\SBS Upgrade Package\SQL_Script_Files` folder and use a text editor to open `SSDT_cmd_Line.bat`.
2. Before running the script, make the following changes to the file in this order:
   1. In a text editor open `SSDT_cmd_Line.bat`, right-click and select Edit.

   2. Verify the Microsoft SQL Server path is correct. Edit the path if it is not the following:

      `SET "PathToSqlPackage=Microsoft SQL Server\120\DAC\bin\sqlpackage.exe"`

   3. Verify that the SQL path and the SQL Instance are correct. Change if different from the following:
      - The MDFPath and the LDFPath need to reflect the SQL Version being used and the SQL Instance respectively, NOT the database path.
      - SQL 2008R2 will be `MSSQL10_50.<SQL Instance>\MSSQL\DATA`
      - SQL 2012 will be `MSSQL11.<SQL Instance>\MSSQL\DATA`
      - SQL 2014 will be `MSSQL12.<SQL Instance>\MSSQL\DATA`
   4. (Optional) If the PME system is not installed at the default file location, edit the following parameter to match to the system’s exact file path:

      `SET PMEPath=C:\Program Files (x86)\Schneider Electric\Power Monitoring Expert`

1. After saving the file, execute it by double-clicking on the file name.

After the above batch file is executed, close the prompt window. An `ApplicationModules.sql` file is created in the `...\SBS Upgrade Package`.

1. Before running the `ApplicationModules.sql` file, enable the SQLCMD mode:
   1. In SQL Server Management Studio click Tools > Options > Query Execution > SQL Server > General.
   2. Select By default, open new queries in SQLCMD mode, then click OK.

1. In SQL Server Management Studio open the `ApplicationModules.sql` file and then click Execute to run the script.
2. After running the `ApplicationModules.sql` file, disable the SQLCMD mode:
   1. In SQL Server Management Studio click Tools > Options > Query Execution > SQL Server > General.
   2. Uncheck By default, open new queries in SQLCMD mode, then click OK.
3. Update the DataSourceSignature:
   1. In SQL Management Studio, go to the ApplicationModules.DataSourceBus.DataSource table.
   2. Right-click the table and select top 1000 rows.
   3. Copy the Signature by right-clicking and selecting Copy.

1. In a text editor open `…\Schneider Electric\Power Monitoring Expert\Applications\bin\DataServicesHost.config` and then update the `DataSourceSignature` value to match the one you copied in the image above.

Note: Once the upgrade is complete, it is recommended that you make a backup of the upgraded databases. Should your database become corrupted at a later time, this backup of the upgraded databases will help you to complete the upgrade successfully. A suggested location for these backups is `…\Schneider Electric\Power Monitoring Expert\config\cfg\DBBackups`.