This question already has an answer here:

I want to migrate data contained in an Oracle Table A to SQL Server. The table A contains a column CIN with unique constraint but mutliple null values. The problem is that SQL Server is rejecting the data. Is there any workaround for this ?

marked as duplicate by Kenneth Fisher, Aaron Bertrand Oct 28 '14 at 15:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • @AaronBertrand, wasn't that just a few days ago? I had not seen that but yes, this appears to be a duplicate of that one. – Solomon Rutzky Oct 28 '14 at 15:13
  • yes I think it's a duplicate :) the site didn't suggest that question to me.. – mounaim Oct 28 '14 at 15:19

You can use a Filtered Index to remove the NULL values from consideration regarding uniqueness. You would first drop the existing UNIQUE CONSTRAINT and then replace it with a UNIQUE INDEX. These two objects are essentially the same given that a UNIQUE CONSTRAINT actually exists via a UNIQUE INDEX (the documentation for creating a column constraint states that UNIQUE is a "constraint that provides entity integrity for a specified column or columns by using a unique index.").

ON SchemaName.TableA (CIN ASC)
  • 1
    Thank you @srutzky for the complete documentation of the answer :) – mounaim Oct 28 '14 at 15:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.