Sql-server – Sequence and table with the same name

sequencesql serversql-server-2012

Can we have a sequence and table with the same name? I am trying to create a sequence with the same name as an existing table, but I get this error:

There is already an object named 'XYZ' in the database.

I haven't found any documentation about this.

Best Answer

An attempt to document this is made here:

CREATE SEQUENCE (Transact-SQL)

sequence_name
Specifies the unique name by which the sequence is known in the database.

It is not very clear that the name must be unique across all objects in the database. And even that is not true. The name must be unique within the schema in a database.