help me create UNIQUE Constraints

  • I want: on my table (Department_ID nvarchar(2),Possition_ID nvarchar(2))

    never occur: exists

    SELECT Department_ID FROM MyTable

    WHERE Possition_ID = '00'

    GROUP BY Department_ID HAVING COUNT(Possition_ID) >= 2

  • To all posters: please read the original thread before responding, so that you get the whole picture.

    Edit: but I see the OP deleted the original post over there, and replaced it. He was wanting to implement this test in a trigger, to allow multiple occurrences of Possition_ID for each Department_ID except for Possition_ID = '00'.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

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

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