I\'m using SQL Server 2008.
I have a NVARCHAR(MAX) column called Title and i want to add an unique index for it. Because the column is bigger than 9
The hashbytes column gets created as a VARBINARY(MAX)
unless you do specifically tell it that 20 bytes are plenty:
alter table dbo.Softs
add TitleHash AS CAST(hashbytes('SHA1', [Title]) AS VARBINARY(20)) PERSISTED
Once you've done that, then you can create your index (unique or not) on that column:
CREATE UNIQUE NONCLUSTERED INDEX [UIX_TitleHash]
ON [dbo].[Softs]([TitleHash] ASC)
Now this should work just fine.