Restoring deleted entities

Prev Next

Step-by-Step Guide to Restore an entity

1. Find the Revision Command ID

Take Note!

Revision* tables are soon going to be moved to a different server, so instead of Revision* tables use vwRevision* views.

First, you need to find the RevisionCommandId associated with your specific object. In the following example, we retrieve a deleted ECH by its Name.

SELECT rc.RevisionCommandId, rc.ObjectId, rf.FieldName, rf.FieldValue
FROM RevisionCommand as rc
inner join RevisionField as rf on rf.RevisionCommandId = rc.RevisionCommandId
WHERE rc.ActionCommandType = 2 and rc.ObjectType = 'ECH' and rf.FieldName = 'Name' and rf.FieldValue = 'ECHNAME'

2. Run the Stored Procedure to Restore the Object

Once you have identified the object, follow the stored procedure to restore it. Use the following command and fill in the ObjectTypecode specific to your Object to restore in this case ECH:

EXEC utils.spRestoreObject
    @ObjectTypeCode = 'ECH',
    @ObjectName = NULL,
    @ObjectId = 0000000,
    @Debug = 0

This stored procedure restores the ECH object with the specified ObjectId.

3. Update the Statistics

Finally, update the statistics for the restored Object by executing the following stored procedure:

In this example, we’ve taken the ECH statistics but depending on your Object find the correct spUpdate___Statistics.

EXEC spUpdateECHStatistics @ObjectId = 0000000, @Create = 1;

This command updates the statistics for the Object with the specified ObjectId.