What it means
Inside one schema, tables, views, procedures, functions, triggers, synonyms and constraints (primary
keys, foreign keys, UNIQUE, CHECK and DEFAULT constraints) all share one set of names. Your
CREATE used a name something in that schema already has, so SQL Server refused it.
Msg 2714, Level 16, State 6, Server 7732422b7f56, Line 1
There is already an object named 'customers' in the database.
“In the database” really means in that schema: sales.customers and dbo.customers can both exist.
The object in the way isn’t always the kind you’re creating. A view can clash with a table, and a
constraint name with a constraint on a different table, in which case a second error follows:
Could not create constraint or index. See previous errors. (1750).
Common causes
- A setup or migration script run a second time, so its
CREATE TABLEmeets the table it made the first time. - A constraint name already used in the schema. Copying
CONSTRAINT PK_customers PRIMARY KEYinto a new table’s definition, or a default namedDF_statuson two tables. - Named constraints on temp tables.
#temptables get unique internal names per session, but their constraint names don’t. When two sessions run the same procedure withCREATE TABLE #t (id int CONSTRAINT PK_t PRIMARY KEY), the second one fails. - The same temp table created twice in one batch or procedure. SQL Server checks this when it
compiles the batch, so it fails even when the two
CREATE TABLE #tstatements are in different branches of anIF … ELSE, or aDROP TABLE #tsits between them. SELECT … INTOan existing table.SELECT … INTOalways creates the target.
How to fix it
Find what holds the name
SELECT SCHEMA_NAME(o.schema_id) AS [schema], o.name, o.type_desc,
OBJECT_NAME(o.parent_object_id) AS parent_table
FROM sys.objects AS o
WHERE o.name = N'PK_customers';
parent_table shows which table a constraint belongs to. If it’s a leftover from an earlier run,
drop it; if it’s someone else’s, pick a different name.
Make the script safe to re-run
Drop first, when losing the old object (and a table’s data) is what you want; IF EXISTS needs
SQL Server 2016 or later:
DROP TABLE IF EXISTS dbo.import_rows;
CREATE TABLE dbo.import_rows (id int PRIMARY KEY, payload nvarchar(400));
Create only if it’s missing, when the existing table must be kept:
IF OBJECT_ID(N'dbo.import_rows', N'U') IS NULL
CREATE TABLE dbo.import_rows (id int PRIMARY KEY, payload nvarchar(400));
For views, procedures, functions and triggers, CREATE OR ALTER (SQL Server 2016 SP1 and later)
replaces the definition and keeps the permissions granted on it:
CREATE OR ALTER VIEW dbo.open_orders AS
SELECT id, customer_id, total FROM dbo.orders WHERE status = 'open';
Don’t name constraints on temp tables
Let SQL Server name them, and the names are unique per session
(PK__#t2_______3213E83F325B419A in the test below):
CREATE TABLE #work (id int PRIMARY KEY, total decimal(10, 2));
In a procedure that needs different shapes in different branches, use a different temp table name in
each, or create the table once and ALTER TABLE it.
Insert into an existing table instead of SELECT … INTO
INSERT INTO dbo.order_archive (id, customer_id, total)
SELECT id, customer_id, total FROM dbo.orders WHERE created_at < '2026-01-01';
Reproduce it
On SQL Server 2022 (16.0.4295.3) with sqlcmd, in a scratch schema that already had a table
customers:
CREATE TABLE seo_err_mssql.customers (id int);
CREATE TABLE seo_err_mssql.tags (id int CONSTRAINT PK_customers PRIMARY KEY);
CREATE TABLE seo_err_mssql.labels2 (id int CONSTRAINT PK_customers PRIMARY KEY);
each in its own batch: the first failed, the second created tags, and the third reused the
constraint name:
Msg 2714, Level 16, State 6, Server 7732422b7f56, Line 1
There is already an object named 'customers' in the database.
Msg 2714, Level 16, State 5, Server 7732422b7f56, Line 1
There is already an object named 'PK_customers' in the database.
Msg 1750, Level 16, State 1, Server 7732422b7f56, Line 1
Could not create constraint or index. See previous errors.
CREATE VIEW seo_err_mssql.tags gave 2714 with state 3, and SELECT 1 AS a INTO seo_err_mssql.tags
state 6. Two CREATE TABLE #work in one batch, a procedure that creates, drops and creates #x, and
an IF 1 = 0 … ELSE … that creates #a in each branch:
Msg 2714, Level 16, State 1, Server 7732422b7f56, Line 2
There is already an object named '#work' in the database.
Msg 2714, Level 16, State 1, Server 7732422b7f56, Procedure p, Line 5
There is already an object named '#x' in the database.
Msg 2714, Level 16, State 1, Server 7732422b7f56, Line 5
There is already an object named '#a' in the database.
The procedure was never created, and the IF batch failed even though only one branch could run.
Two sessions a second apart each ran CREATE TABLE #t1 (id int CONSTRAINT PK_t1 PRIMARY KEY); the
second got 2714 for 'PK_t1' and 1750, while the first still held its table. Without the constraint
name, both worked. DROP TABLE IF EXISTS followed by CREATE TABLE, and CREATE OR ALTER VIEW run
twice, gave no errors. SQL Server 2019 and 2025 printed the same messages.
In Inlet
The sidebar lists each schema’s tables, views, sequences, functions and procedures from the sys views,
so you can see what already has the name. The structure designer writes T-SQL that names its default
constraints, and shows the DDL before it runs. When SQL Server refuses, Inlet shows its message with
SQL Server error 2714, state 6, severity 16 and links to this page.