SQL Source Control 5

Set up object locking

Object locking is only compatible with SQL Server 2008 and later.

Object locking isn't compatible with Amazon RDS or Azure SQL Database.

To set up object locking, you need to run a script on the server. Afterwards, you can lock objects in all databases on the server.

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

To run the setup script, you need these database 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

  1. In the Locking tab, click Open setup script.
  2. Click Run script.
    The script opens in a new Management Studio query window.
  3. Close any other query windows that use the RedGate database.
  4. Run the script.

Object locking is set up for the server.


Didn't find what you were looking for?