locked
Regarding SQL Server Sql statements RRS feed

  • Question

  • User-1940827647 posted

    I have tblEmployee table,tblDesignationTable

    I have given a FK PK relationship between these two tables.

    Designation table contains

    Designation       DesignationId

    Chairman               1

    CEO                       2

    Manager               3
    Team Leader         4
    Programmer         5
    Tester                   6

    -----------------------------

    So, my problem is 

    we must have only one record for chairman and one record for CEO.

    remaining designations can have multiple records.

    How to do this.. please help me

    Saturday, March 5, 2016 10:51 AM

Answers

  • User-158764254 posted

    you can use a trigger.

    in the trigger, if a chairman is being set, see if one already exists.  if a chariman already exists, either abort the transaction or remove the assignment from the preexisting chairman

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, March 5, 2016 12:17 PM