Results 1 to 3 of 3

Thread: Unique Key Constraint

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Malaysia
    Posts
    345

    Unique Key Constraint

    I need to put a unique key constarint on two fields on a table which I have made in the Sql Server. Please help me in the syntax.
    Thanks.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Malaysia
    Posts
    345
    can II put the unique key constraint on a bit field. I need to put the constraints on two fields one of which is a bit field. That field is for marking the record as deleted or existing.
    Thanks.

  3. #3
    Frenzied Member PilgrimPete's Avatar
    Join Date
    Feb 2002
    Posts
    1,313
    I don't think it matters what the data type is - just that the field does not allow NULLs.

    Code:
    CONSTRAINT myConstraint UNIQUE NONCLUSTERED (field1, field2)
    Here's what MSDN has to say on the subject:
    http://msdn.microsoft.com/library/de...eate2_8g9x.asp

Posting Permissions

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



Click Here to Expand Forum to Full Width