I am currently migrating MS Access to SQL Server. Since Access allows multiple Nulls on unique indexes where SQL Server does not work ... I handled the migration by removing indexes in SQL Server and adding filtered indexes:CREATE UNIQUE NONCLUSTERED INDEX idx_col1_notnull ON tblEmployee(col1) WHERE col1 IS NOT NULL;
The problem I am facing is that I am not sure how to implement compound or multi-column “filtered” indexes ... or if it is really possible, since I did not find any examples for research.
I have an idea to implement it by creating filtered indexes as follows:
CREATE UNIQUE NONCLUSTERED INDEX idx_col1col2_notnull ON tblEmployee(col1,col2) WHERE col1 IS NOT NULL
And then adding a second filtered index:
CREATE UNIQUE NONCLUSTERED INDEX idx_col2col1_notnull ON tblEmployee(col1,col2) WHERE col2 IS NOT NULL
But I'm not sure that this will even work, not to mention the best method. Leading in the right direction would be very helpful.
source
share