Fix “The new name is already in use as a COLUMN name and would cause a duplicate that is not permitted” in SQL Server (Error 15335)

If you’re getting an error that reads something like “Error: The new name ‘c1’ is already in use as a COLUMN name and would cause a duplicate that is not permitted” in SQL Server, it appears that you’re trying to rename a column with a name that already exists in that table.

Basically, there’s already a column of that name in the table.

To fix this issue, provide a name that isn’t already used by a column in that table.

Example of Error

Here’s an example of code that produces the error:

-- Create the table
CREATE TABLE dbo.t1 (
    c1 int,
    c2 int
);

-- Rename column
EXEC sp_rename 'dbo.t1.c2', 'c1', 'COLUMN';

Output:

Msg 15335, Level 11, State 1, Procedure sp_rename, Line 527
Error: The new name 'c1' is already in use as a COLUMN name and would cause a duplicate that is not permitted.

As the error messages tell us, column names must be unique within each table. Using that column name would cause duplicate duplicate column names, which isn’t allowed.

Solution

To fix this issue, make sure each column name is unique within its table.

Here’s an example of fixing the issue:

EXEC sp_rename 'dbo.t1.c2', 'c3', 'COLUMN';

Output:

Caution: Changing any part of an object name could break scripts and stored procedures.

Success. The “caution” message is just there to warn us that changing column names could cause problems for other scripts and objects that reference or rely on this column. It’s good practice to review your database before changing the names of columns, objects, etc.