Set up object locking
Published 16 July 2015
About the setup script
The script adds the trigger RG_SQLSourceControl_DDLTrigger to the server. The trigger detects when somebody tries to edit a locked object.
The script also creates the database Redgate with the schema SQLSourceControl. This contains:
- the table SQLSourceControl.LockedObjects, to store locks on objects
- the function SQLSourceControl.GetLockedObjects, to retrieve locked objects
- the function SQLSourceControl.IsObjectLocked, to check if objects are locked
- the stored procedure SQLSourceControl.LockObject, to lock objects
- the stored procedure SQLSourceControl.UnlockObject, to unlock objects
Required privileges
CREATE USER
CREATE ROLE
GRANT ANY PRIVILEGE
CREATE ANY TABLE
CREATE ANY PROCEDURE
You don't need the privileges to lock and unlock objects.
To set up object locking in SQL Source Control
- In the Locking tab, click Open setup script.
- Click Run script.
The script opens in a new Management Studio query window. - Close any other query windows that use the RedGate database.
- Run the script.
Object locking is set up for the server.