I hava a table that stores payment information, with invoicenumber int and part varchar, where part can be (1/1, 1/2, 2/2, 1/3, 2/3, 3/3, etc)

The thing is not all payments are related to invoices, so I have many null value for invoicenumber.

Is it posible to create a UNIQUE INDEX on (invoicenumber, part) that ignores NULL values on invoicenumber?

tks for any help

I hava a table that stores payment information, with invoicenumber int and part varchar, where part can be (1/1, 1/2, 2/2, 1/3, 2/3, 3/3, etc)

The thing is not all payments are related to invoices, so I have many null value for invoicenumber.

Is it posible to create a UNIQUE INDEX on (invoicenumber, part) that ignores NULL values on invoicenumber?

tks for any help

AFAIK MSSQL does not support partial indexes (like PostgreSQL, Teradata, Oracle etc).

You may be able to get the functionality you require using a indexed view.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.