Reputation: 75
Trying to alter a table in SQL Server. I want to add a unique constraint to a column called Names
in table ReportingItemNames
:
ALTER TABLE ReportingItemNames
ADD CONSTRAINT UC_ReportingItemNames$Name UNIQUE ([ReportingItemNames,Name])
But I am getting this error:
Column name 'ReportingItemNames,Name' does not exist in the target table or view
Where am I going wrong?
Upvotes: 0
Views: 164
Reputation: 33381
Use this:
ALTER TABLE ReportingItemNames
ADD CONSTRAINT UC_ReportingItemNames UNIQUE ([Name])
You can refer to ALTER TABLE (Transact-SQL) documentation for more information.
Upvotes: 3
Reputation: 7270
Shouldn't it be:
ALTER TABLE ReportingItemNames
ADD CONSTRAINT UC_ReportingItemNames$Name UNIQUE ([Name])
Upvotes: 1