As a second part of this work, I’ve made sure that unique constraints on nullable columns have a consistent semantic across databases including DB2 and SQL Server. When the unique key includes a nullable column, we now generate: create unique nonclustered index name on table (column) where column is not null on SQL Server (after 2008). And on DB2 (after 10.5) it is either: create unique index name on table (column) exclude null keys or, on i or Z series: create unique where not null index name on table (column) As an aside I have no clue when the where not null syntax was introduced, which is an issue for the community dialects. Now, the bad guy is Sybase. There’s still no way to do this on Sybase, since Sybase is essentially unmaintained. My solution is, for maximum portability, simply ignore unique constraints involving nullable columns on Sybase. I realize this is a debatable decision, but I think it’s the best and most consistent option. |