sql - Unique constraint excluding NULLs in UDT field -
i using sql server 2012 , have following user defined table type
create type [dbo].[identifiercodetable] table( [id] [dbo].[identifier] null, [code] [dbo].[code] null )
i trying enforce id
must unique
except null
values. have following code , working fine non null
values when try insert 2 null
values not allow me it.
create type [dbo].[identifiercodetable] table( [id] [dbo].[identifier] null, [code] [dbo].[code] null, unique(id) )
is there way exclude null
values unique constraint can in regular indexes filter?
i think need know (it sql server 2008 think applies sql server 2012 either).
a nonclustered index cannot created on user-defined table type unless index result of creating primary key or unique constraint on user-defined table type. (sql server enforces unique or primary key constraint using index.)
source: https://technet.microsoft.com/en-us/library/bb522526%28v=sql.105%29.aspx
Comments
Post a Comment