Guest User

Untitled

a guest
Feb 18th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. CREATE TYPE [dbo].[MyTableType] AS TABLE
  2. (
  3. Id INT NULL INDEX ix UNIQUE WHERE Id IS NOT NULL /*Unique ignoring nulls*/
  4. , Sort INT NOT NULL
  5. , [Name] NVARCHAR(MAX) NULL
  6. )
  7.  
  8. CREATE TYPE [dbo].[MyTableType] AS TABLE
  9. (
  10. Id INT NULL UNIQUE
  11. , Sort INT NOT NULL
  12. , [Name] NVARCHAR(MAX) NULL
  13. )
  14.  
  15. CREATE UNIQUE NONCLUSTERED INDEX idx_yourcolumn_notnull
  16. ON YourTable(yourcolumn)
  17. WHERE yourcolumn IS NOT NULL;
  18.  
  19. CREATE TYPE [dbo].[MyTableType] AS TABLE (
  20. MyTableTypeId int identity(1, 1),
  21. Id INT NULL,
  22. Sort INT NOT NULL,
  23. [Name] NVARCHAR(MAX) NULL,
  24. _ix as (coalesce(id, - MyTableTypeId)),
  25. unique (_ix)
  26. );
Add Comment
Please, Sign In to add comment