Help with Constraint

  • Table

    ID

    CatID

    ProductName

    I want to write a constraint that would require distinct productname per CatID.

    thanks

     

     


    </cm>

  • Create a composite index that contains both ProductName and CatID and using EM set to Unique Constraint.

    Or SQL Syntax

    ALTER TABLE dbo.tblName ADD CONSTRAINT

     IX_tblName UNIQUE NONCLUSTERED

     (

     ProductName,

     CatID

    &nbsp ON [PRIMARY]

    Above assumes ProductName will have more distinct values and thus a higher statistics factor will be produced for the Constraint index.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply