Configuring Responder/Smart Grid
Implementation Scripts - SQLServer

Version: 10.1

Resource Center Home

The following implementation scripts must be run on your Responder SQLServer database to add the correct tables, views, and indices. When performing a new Responder implementation execute ONLY the Implementation Scripts. Do NOT execute any Upgrade scripts.

Responder requires two databases: Responder and Archive. Some scripts are run on the Responder database and some on the Archive database. In the list below, the database on which the script should be executed is in parentheses.

  1. Create a new database on your SQL Server instance to house the Responder database. An existing database can be used, but it might be easier to manage (backups, disk storage, etc.) if you create a new database dedicated to the Responder tables.
  2. Create the RESPONDER user in the SQL Server instance (this is your database owner). Grant this user access to the database discussed in step 1.
  3. Open a new query, connecting to the database discussed in step 1 as the new RESPONDER user.
  4. Execute 01_RxTables.sql. This script creates the database tables required by Responder.
  5. The 02_ArcJoinViews.sql script creates the views that are used to display Responder data in ArcMap. Before executing this script, you may need to modify the feature class names within it to match those in your geodatabase. Open the script and ensure that the feature class names in the script match the corresponding feature class names in your geodatabase. The ownership is set to ArcFM and needs to be modified if you are not using ArcFM (such as SQL users.) Execute 02_ArcJoinViews.sql.

If your SDE tables reside in a database other than SDE, you will need to edit the script to set the correct database name. For example, if your database is named DB, then the following would change:

FROM SDE.SDE.GDB_ITEMS

It would become:

FROM DB.SDE.GDB_ITEMS

Be sure to search the script for all instances of SDE.SDE. and modify to include the correct database name.

  1. Create a new database on your SQL Server instance to house the Archive database. An existing database can be used, but creating a new database dedicated to the Archive tables is recommended, since it will be easier to manage (backups, disk storage, etc.).
  2. Execute 03_ArchiveTables.sql on the Archive database. This script creates the tables used by Archive Services and Archive Explorer.
  3. Open 04_GenerateGrants.sql in a text editor (e.g., Notepad). This script generates a grant script that must also be run on both the Responder and Archive databases. Before executing, you must determine the roles and the permissions you wish to assign them. The roles must exist in both the Responder and Archive databases. You may assign permissions to several different roles. Look for the following lines of code in the script:
-- rx_editor role can edit data in responder or archive schema
select 'grant insert, update, delete, select on ' 
+ table_name + ' to rx_editor ;' 
from information_schema.tables where table_type = 'base table' and table_schema = 'responder'
go
select 'grant select on ' 
+ table_name + ' to rx_editor ;' 
from information_schema.tables where table_type = 'view' and table_schema = 'responder'
go

-- rx_viewer role can view data in responder schema
select 'grant select on ' 
+ table_name + ' to rx_viewer ;' 
from information_schema.tables where table_type = 'base table' and table_schema = 'responder'
go
select 'grant select on ' 
+ table_name + ' to rx_viewer ;' 
from information_schema.tables where table_type = 'view' and table_schema = 'responder'
go

The table_schema = 'responder' portion above refers to the database owner (Responder).

The first four lines assign permissions to a role for tables. The second set of four lines assign permissions to a role for views (views can only be assigned the Select permission). The last eight lines perform the same tasks as the first half, but for views rather than tables. You will need a set of lines for each role to which you wish to assign permissions to tables and views. The next few steps describe how to perform the modifications you may wish to make for each role.

You may execute the same script for the Responder database and Archive database. The script MUST be executed on both databases.

  1. The "grant insert, update, delete, select" portion determines which permissions are to be assigned. Modify these permissions as necessary.
  2. Replace "rx_editor" with the name of the role to assign the permissions. There are two possible roles: rx_editor and rx_viewer.
  3. When you've finished adding statements for roles, close and save the file.
  4. Open 04_GenerateGrants.sql in SQL Server Query Analyzer.
  5. Right-click in the top grid (with the query) and select Results to Text.
  6. Execute 04_GenerateGrants.sql. Remember, this script only generates a script that sets permissions. Below is an example of the resulting script:
grant insert, update, delete, select on RX_TAG_GROUND_STEPS_HISTORY to rx_editor ;
grant insert, update, delete, select on RX_TAGS_AND_GROUNDS to rx_editor ;
grant insert, update, delete, select on RX_TAGS_AND_GROUNDS_HISTORY to rx_editor ;
grant insert, update, delete, select on RX_TRUCKS to rx_editor ;
grant insert, update, delete, select on RX_TRUCKS_HISTORY to rx_editor ;
grant insert, update, delete, select on RX_USERS to rx_editor ;

(41 row(s) affected)

                                                                                                                                                                
--------------------------------------------------------------------------------------- 
grant select on Current_Outages to rx_editor ;
grant select on RX_CREW_ASSIGNMENT_COUNT_VIEW to rx_editor ;
grant select on RX_CREW_INCDEV_DPD_VIEW to rx_editor ;
grant select on RX_CREW_INCDEV_FUS_VIEW to rx_editor ;
  1. Remove the highlighted portions above and any extra empty returns. Copy the script and paste it into a new query. Copy only the "grant..." lines.
  2. Execute the copied query to assign permissions to roles. The permissions assigned apply to all Responder tables and views.

The final script (05_SnapshotIsolation.sql) requires that the user executing it have sysadmin privileges. To execute the script, only the connection running the script should connect to the database. If any other connections are present, the query will try to execute indefinitely.

  1. Lastly, execute 05_SnapshotIsolation.sql. You will need to execute this script on the both the Responder and Archive tables. This script configures your SQL database to use Read Committed Snapshot Isolation. You will receive errors if this is not configured. Responder supports Read Committed Snapshot Isolation to provide performance enhancements.

Send Comment to documentation@schneider-electric.com