SQL Server 2012: Msg 11730, Database name cannot be specified for the sequence object in default constraints

In this post, I am providing solution to use a single Sequence object between different databases.

Generally, we are creating a sequence constraint to assign a sequence object to a particular table, but here table and sequence both are on the same database.

Sometimes, we also require to use a Sequence object of an another database.
Unfortunately, you cannot specify another database name when you are creating a default sequence constraint.

Below is a full demonstration on this error and solution.

First, create one Sequence object:

I have created this sequence into AdventureWorks2012 database.

Now use this created Sequence object into TempDB:

You will get this error message:

SQL Server Sequence Database Name Error

The solution is to use Sequence object with INSERT statement:

The Result:

SQL Server Sequence Database Error Result

Anvesh Patel

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz