Can anyone help me achieve this. I want to enforce a constraint across 2 columns but that constraint will not be enforced if one of the values is NULL.
table columns: ID int, PROGRAMID int, USERNAME varchar(50).
Every record must have a PROGRAMID but any record can have USERNAME NULL. However the combination of PROGRAMID and a non NULL USERNAME must be unique.
How can I achieve this without using triggers or other higher level logic.