I\'m using SQL Server 2008.
I\'ve got a column NVARCHAR(MAX)
in a table which I want to make sure is unique.
The table has 600,000 records and grows ev
It's madness not to have an index.
It would help but the index key length can only be 900 bytes.
However, it's likely you already have duplicates because the potential for a 2nd EXISTS to run after the 1st EXISTS but before the 1st INSERT.
The index creation will tell you, and subsequently protect against this.
However, you can get errors under heavy load.
My favoured approach for high inserts/low duplicates is the JFDI pattern. Highly concurrent
BEGIN TRY
INSERT etc
END TRY
BEGIN CATCH
IF ERROR_NUMBER() <> 2627
RAISERROR etc
END CATCH