sql server - Error adding unique constraint: Column in table is of a type that is invalid for use as a key column in an index -


this question has answer here:

if have primary key on column id , have column name on want add unique constraint, how can in sql server?

i tried following:

alter table dbo.hotels add constraint         unq_name unique nonclustered (             name ) 

error:

msg 1919, level 16, state 1, line 1 column 'name' in table 'hotels' of type invalid use key column in index. 

name represented as:

name nvarchar(max) allow nulls 

the syntax is:

alter table <tablename> add constraint         <constraintname> unique nonclustered (             <columnname> ) 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -