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.

Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

If you like this post, then please share it with others.
Please follow dbrnd.com, I will share my experience towards the success of Database Research and Development Activity.

I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.

More from dbrnd.com

Leave a Reply

Be the First to Comment!

Notify of