Results 1 to 5 of 5

Thread: UNIQUE INDEX if not NULL

  1. #1
    Join Date
    Apr 2006
    Posts
    178

    UNIQUE INDEX if not NULL

    Hello !

    for MS SQL 2000
    how can i set an unique index on Serial column but only if Serial IS NOT NULL

    CREATE UNIQUE INDEX [IX_Product] ON [Product]([Serial]) ON [PRIMARY]

    i can have 100 rows with a NULL Serial


    thank you

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    Don't really understand your question. You can only create unique index on column that doesn't allow null.

  3. #3
    Join Date
    Apr 2006
    Posts
    178
    but i need a column allowing NULL, and if the value IS NOT NULL it must be UNIQUE

  4. #4
    Join Date
    Sep 2002
    Posts
    5,938
    Can't do it with unique index, may need trigger to enforce that.

  5. #5
    Join Date
    Apr 2006
    Posts
    178
    thank you, i shall do it from outside (.NET)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •