Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TYPE [dbo].[MyTableType] AS TABLE
- (
- Id INT NULL INDEX ix UNIQUE WHERE Id IS NOT NULL /*Unique ignoring nulls*/
- , Sort INT NOT NULL
- , [Name] NVARCHAR(MAX) NULL
- )
- CREATE TYPE [dbo].[MyTableType] AS TABLE
- (
- Id INT NULL UNIQUE
- , Sort INT NOT NULL
- , [Name] NVARCHAR(MAX) NULL
- )
- CREATE UNIQUE NONCLUSTERED INDEX idx_yourcolumn_notnull
- ON YourTable(yourcolumn)
- WHERE yourcolumn IS NOT NULL;
- CREATE TYPE [dbo].[MyTableType] AS TABLE (
- MyTableTypeId int identity(1, 1),
- Id INT NULL,
- Sort INT NOT NULL,
- [Name] NVARCHAR(MAX) NULL,
- _ix as (coalesce(id, - MyTableTypeId)),
- unique (_ix)
- );
Add Comment
Please, Sign In to add comment