SQL Server 2012: Error Msg 3729 Cannot DROP SEQUENCE because it is being referenced by Object

The database Sequence Object introduced with SQL Server 2012 and we can use and assign single Sequence object to multiple table.

In this post, I am sharing one script to find all dependencies of the SQL Server Sequence object so that we can drop a Sequence object easily.

Below is one small demonstration, in which I have created one Sequence object and assigned to two different tables.

First, Create a Sequence object:

Create two different tables:

Assign this Sequence object to both the tables:

Now try to drop this Sequence object:

You will get this error,

SQL Server Sequence Error

Script to find and generate Alter command for all dependency:

The result:

SQL Server Sequence Drop Constraint

Before dropping a Sequence object, we should drop all Sequence object constraint so copy this result and drop both constraint before dropping a Sequence object.

Anvesh Patel

Leave a Reply

Be the First to Comment!

Notify of