Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想定义一个唯一的列,但前提是它不为空。
我的意思是可以有多个空值,但是当它们不为空时,它们必须不同。我怎样才能做到这一点?
在 SQL Server 2008 及更高版本中,您可以在索引上指定条件
CREATE UNIQUE NONCLUSTERED INDEX IX_Filtered_Index_Name ON your_table (some_column) WHERE some_column IS NOT NULL