<< Click to Display Table of Contents >>
Navigation: Database >
Delete a Facility
•Method 1: Use Delete Facility Stored Procedure
•Method 2: Use Cascade Delete in EQuIS Professional
If a situation arises where you may need to completely remove a facility from an EQuIS Database, there are two methods for doing this. Prior to deleting a facility, EarthSoft highly recommends that you create a current backup of the database before deleting a facility.
Warning: Deleting a facility is permanent and irreversible, and should only be done after careful consideration and planning. The only way to undo this operation is to restore a backup copy of your database.
The EQuIS Database Schema includes a stored procedure that will delete a facility from the database.
1.Open the DT_FACILITY table to find the correct FACILITY_ID value of the facility you want to delete in EQuIS Professional.
Warning: Make sure the correct FACILITY_ID value is used to prevent inadvertently deleting the wrong facility.
2.Close EQuIS Professional. Check to make sure no other users are connected to the facility that will be deleted. Remove that facility access for inactive users.
3.Start SQL Server Management Studio and log in to SQL Server.
4.Expand Databases in Object Explorer.
5.Select the EQuIS Database that contains the facility to delete.
Warning: Select the correct database (if there are multiple EQuIS Databases), to prevent inadvertently deleting the wrong facility.
6.Click New Query on the toolbar and paste the query shown below using your FACILITY_ID value on line five (instead of 999999).
DECLARE @facility_id int
7.Double-check that the facility is correct and should really be deleted. Deleting a facility cannot be undone!
8.Execute the query to delete the facility.
If the message, "Msg 207, Level 16, State 1, Procedure esp_table_order, Line 25 Invalid column name 'id'" is received, first execute this procedure before executing the above equis.delete_facility procedure.
Warning: References to a facility are much more complex than for most tables due to inability to have foreign key constraints on some FACILITY_ID fields that can also reference facility group IDs as well as to records in DT_FACILITY.
Because the Professional Cascade Delete functionality relies on foreign key constraints, this method is not the best way to delete a facility from an EQuIS Database. Using the EQUIS.DELETE_FACILITY stored procedure as described in Method 1 should be used instead. However, if the desired action is to delete only those fields that have a foreign key constraint, then this method can be used.
EQuIS Professional includes a Cascade Delete button that is enabled when logged into the database as a database owner. Delete a facility using the Cascade Delete button by following the steps below.
1.Check and make sure no other users are connected to the facility that will be deleted. Remove that facility access for inactive users.
2.Open EQuIS Professional and log in to the same database, but to a different facility than the facility that will be deleted.
3.Open the DT_FACILITY table using the Table (All Rows in Database) option.
4.Select the row for the facility to be deleted.
5.Click Cascade Delete on the toolbar.
6.Deleting a facility cannot be undone. Make sure you really want to delete the facility.
7.Click Yes to confirm the facility will be deleted.
8.The process of the rows for that facility being deleted from all tables in the database may take several minutes.
9.Review the list of rows that have been deleted (right-click on the grid and save summary information to an *.XML file for future reference).
10.Click Finish to commit the transaction, and permanently delete the rows. (Click Cancel if deleting the facility is no longer desired).
Copyright © 2023 EarthSoft, Inc • Modified: 03 Apr 2023