Unique Index

  • I need to create a Unique Index based on an integer field plus the year component of a date field.

    Does anyone know if something like this is possible

    CREATE UNIQUE NONCLUSTERED INDEX Formid ON dbo.tblMoth

    select (Form,datepart(yyyy,MothAdmi)) WHERE Form IS NOT NULL;

    GO

  • Not directly possible. You'll have to first create a computed column for the year and then index that

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

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

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