Make the database (BPC RM on SQL2005)

From RiskWiki
Jump to: navigation, search

Introduction

Two options are available for creating a new risk database. The first option is easiest (BUT NOT PREFERRED) for users who do not have access to SQL Server tools (Eg Enterprise Manager or SQL Studio). This generally applies only to users of MSDE 2000. The second option is the safest and therefore preferred, but requires access to the Enterprise Manager (SQL 2000) or Database Management Studio (2005/Express) shipped with the database software. Detaching and reattaching Microsoft databases on different computers is not recommended by Microsoft.


The following instructions assume the default drive and directories are used for database files. You may substitute your own locations but must edit the supplied sql files accordingly.


OPTION 1 – Attach Database (NOT PREFERRED in Enterprise)

This is the best method for MSDE 2000 and single user installs.


For MS SQL Server 2005/MS SQL Express 2005

  • Attach database MDF file provided
    • Copy file [RMInstallDir]\Database\MDFToAttach\RiskManDB_Data.MDF to folder: 'C:\Program Files\Microsoft SQL Server\MSSQL.1\Data\'
    • Run batch file: [RMInstallDir]\Database\MDFToAttach\AttachRiskMDFFile2005.bat


Notes: Please edit SQL file (AttachRiskMDFFile2005.sql) if you copy the file to a different location, a new SQL Server log file is automatically created.


Note: If attaching the database manually (ie. Not with the provided scripts, we suggest that you flag the owner of the databases as ‘sa’).


OPTION 2 – Create & Restore Database (PREFERRED)

  • Database can be restored from SQL Server backup file. Follow these steps:


Create database 'RiskManDB’ in SQL Server (2005+)

  • It is a good idea to create a couple of databases. Eg. a Training database, a Production (main) database and possibly a Testing database. You can have as many databases as you like in RiskManager.
  1. Right click on the “DataBases” folder and choose “New Database” from the properties.

    SQLStudMan NewDB1.png

  2. Enter a database name that makes sense to you. We recommend that you adopt a sensible, consistent naming convention for your databases to make management easier later. We suggest you start it with “RiskManDB” ending with a character string that identifies the database. E.G. “RiskManDB_Train08”

    SQLStudMan NewDB2.png

  3. Select OK to generate the new database


Restore the backup file

  • The backup file is held in [RMInstallDir]\Database\BackupToRestore\2005\RiskManDB2005.bak to database. We must force the restore over the existing database file and fix the file locations.


  1. In windows explorer, navigate to the supplied backup master directory: [RMInstallDir] \Database\BackupToRestore\2005\
  2. Either double click on the supplied batch file “CopyMasterToDefaultBackup2005.bat” or manually copy the file:

    [RMInstallDir] \Database\BackupToRestore\2005\RiskManDB2005.bak to the backup directory
    (DO NOT RESTORE DIRECTLY FROM THE SUPPLIED FILE).

    The default SQL 2005 backup directory (and used by the batch file) is: “C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\BACKUP”

    THE BATCH FILE IS ONLY APPROPRIATE IF THE DATABASE SERVER IS ON THE SAME COMPUTER

  3. In Studio Manager Expand the database list for the target server.
  4. Right click on the database you wish to restore (in this case it is the database you just created)
  5. From the Menu that appears choose “Tasks” then “Restore” then “Database…”
  6. The Restore Database window will open. On that window the database name should already be displayed in the :”To Database” field. Select “From device” and click on the ellipsis button on the right hand side.

    SQLStudMan RestoreDV2.png

  7. In the backup selection window, select file from the drop box and select “Add”

    SQLStudMan RestoreDV3.png

  8. Select the backup file we copied into the backup directory and press “OK” and “OK” again.

    SQLStudMan RestoreDV4.png

  9. On the “Restore Database” window tick the “Restore” check box and the select the entire database name from the “To Database” field and copy it (control-C), and then choose “Options”.

    SQLStudMan RestoreDV5.png

  10. On the options panel tick the “Overwrite the existing database” check box.
  11. Now either use the ellipsis buttons to navigate to the correct file name (which will match the database name on the previous screen) and the correct log file (which will match the database name on the previous screen with _log at the end) OR simply replace the file name portion of file path on each line with the string you copied from the previous page on each line.

    SQLStudMan RestoreDV6.png

  12. Then select OK to start the restore.

BackLinks