In a future release of SQL Server, could there be an option that would implement the ANSI/MS Access version of a Unique Key.
As I understand it, the implementation of Unique Key in SQL Server considers Null as one of the values, so that there can only be one entry in the field with Null.
In MS Access and, as I understand it, in the ANSI Standard, there is an option to ignore Null entries in a Unique Key field. In this implementation, there can be many instances where Null is used, but each non-Null value must be unique.
I am building a database and in one of my tables, the field identifies a predecessor record, which could be either Null or one of the other records in the table. In order to ensure that a record is only used once, I would have liked to use the Unique Key, but can't. So, I have had to build a second table, with triggers and foreign keys, and it is ugly. Would have been so much simpler with an ANSI Unique Key.
I understand that this would have to be an option, since there is existing code that probably depends on the current implementation of the Unique Key in SQL Server, but it would have been nice to have the option to use the ANSI Implementation.
Thanks,
Flavelle
Regards,
FlavelleLow priority - the workaround is to build a schema-bound view containing the column to be indexed where the content of the column includes only those non-Null value. A unique index can then be applied to the view.sql
No comments:
Post a Comment