I have multiple nvarchar(max) columns in my DB named ShipperName
,ConsigneeName
, ProdDesc
,BillOFLading
.
What I need to do is to have UNIQUE INDEX
for the combination of these columns. As I am failed to do so because if 900 B limit.
Then I tried(after reading following link Indexing Wide Keys )
ALTER TABLE dbo.ProductDetail
ADD ShipperNameHash AS HASHBYTES('SHA2_512', ShipperName) PERSISTED;
ALTER TABLE dbo.ProductDetail
ADD ConsigneeNameHash AS HASHBYTES('SHA2_512', ConsigneeName) PERSISTED;
Then I got following error on following statement:
Msg 8152, Level 16, State 10, Line 1
String or binary data would be truncated.
The statement has been terminated.
ALTER TABLE dbo.ProductDetail
ADD ProductDescHash AS HASHBYTES('SHA2_512', Product_Description) PERSISTED;
But also above statements created column varbinary(8000)
. Which of course hasn't solved the problem for me.
Is there any way that I can built UNIQUE INDEX
on the combination these columns ?