【发布时间】:2015-04-25 18:09:49
【问题描述】:
如果我已经在 Id 列上有一个主键,并且我有一个 Name 列,我想在该列上添加一个 Unique constraint,我该如何在 SQL Server 中执行此操作?
我尝试了以下方法:
ALTER TABLE dbo.Hotels ADD CONSTRAINT
UNQ_NAME UNIQUE NONCLUSTERED
(
Name
)
错误:
Msg 1919, Level 16, State 1, Line 1
Column 'Name' in table 'Hotels' is of a type that is invalid for use as a key column in an index.
Name 表示为:
Name nvarchar(MAX) Allow Nulls
【问题讨论】:
标签: sql-server