These pages cover SQL Source Control 6, which is not the latest version. Help for other versions is also available.
Remove object locking
Published 16 July 2015
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
CREATE USER
CREATE ROLE
GRANT ANY PRIVILEGE
CREATE ANY TABLE
CREATE ANY PROCEDURE
To remove object locking
View the script:
Object locking uninstall script Toggle source code
- -- 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
- Close any other query windows that use the RedGate database.
- Run the script on the server.
Object locking is removed from the server.