SQL Source Control 6

Remove object locking

To remove object locking from the server, you need to run an uninstall script. Any locked objects on the server will be unlocked.

If you want to uninstall SQL Source Control, you should remove object locking from the server first.

 If you have unlocked objects when you uninstall SQL Source Control, they will stay locked until you either:

  • reinstall SQL Source Control and unlock them in the Locking tab, or
  • run the unlock SQL for each locked object

Required privileges

To remove object locking, you need these database privileges:

  • CREATE USER
  • CREATE ROLE
  • GRANT ANY PRIVILEGE
  • CREATE ANY TABLE
  • CREATE ANY PROCEDURE

To remove object locking

  1. View the script:

    Object locking uninstall script

    -- This script removes the objects added by the object locking setup script. Any locked objects on the server will be unlocked.
    -- Before you run the script, close any other query windows that use the RedGate database.
    -- The script doesn't delete the Redgate database. If you want to delete the database, make sure it isn't being used by other Redgate tools (eg DLM Dashboard).
    -- For more information about object locking, see http://www.red-gate.com/SOC-object-locking
    
    --//////////////////////////////////////
    USE [RedGate]
    --//////////////////////////////////////
    --// DDL Trigger
    --//////////////////////////////////////
    IF EXISTS (SELECT 1 FROM sys.server_triggers WHERE name = 'RG_SQLSourceControl_DDLTrigger')
        DROP TRIGGER RG_SQLSourceControl_DDLTrigger ON ALL SERVER
    GO
    --//////////////////////////////////////
    --// Locked Objects Table
    --//////////////////////////////////////
    IF OBJECT_ID('[SQLSourceControl].[LockedObjects]') IS NOT NULL
        DROP TABLE [SQLSourceControl].[LockedObjects]
    GO
    --//////////////////////////////////////
    --// LockObject Stored Procedure
    --//////////////////////////////////////
    IF OBJECT_ID('[SQLSourceControl].[LockObject]') IS NOT NULL
        DROP PROCEDURE [SQLSourceControl].[LockObject]
    GO
    --//////////////////////////////////////
    --// UnlockObject Stored Procedure
    --//////////////////////////////////////
    IF OBJECT_ID('[SQLSourceControl].[UnlockObject]') IS NOT NULL
        DROP PROCEDURE [SQLSourceControl].[UnlockObject]
    GO
    --//////////////////////////////////////
    --// GetLockedObjects Function
    --//////////////////////////////////////
    IF OBJECT_ID('[SQLSourceControl].[GetLockedObjects]') IS NOT NULL
        DROP FUNCTION [SQLSourceControl].[GetLockedObjects]
    GO
    --//////////////////////////////////////
    --// IsObjectLocked Function
    --//////////////////////////////////////
    IF OBJECT_ID('[SQLSourceControl].[IsObjectLocked]') IS NOT NULL
        DROP FUNCTION [SQLSourceControl].[IsObjectLocked]
    GO
    --//////////////////////////////////////
    --// SQLSourceControl Schema
    --//////////////////////////////////////
    IF (SCHEMA_ID('SQLSourceControl') IS NOT NULL)
        DROP SCHEMA [SQLSourceControl]
    GO
  2. Close any other query windows that use the RedGate database.
  3. Run the script on the server.

Object locking is removed from the server.


Didn't find what you were looking for?