Trigger to update table.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • parshupooja
    New Member
    • Jun 2007
    • 159

    Trigger to update table.

    Hey All

    I have table Employee which has coluumns (id, name, address, ssn, DOB, date of join,level etc )employee records. Everytime there is new employee in company, there is new entry in Employee table.
    I have another table User which has three columns (id, user, password) which consists name of all current employee in user column and ther password is name+123.

    I want to write a trigger which automatically should update the User table with name, name +123 of new user when new employee is added to Employee table.

    Do help,
    Thanks
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Kindly post what you have tried so far.

    Comment

    • parshupooja
      New Member
      • Jun 2007
      • 159

      #3
      I haven't wriiten anything since I don't know much abt Triggers

      Originally posted by debasisdas
      Kindly post what you have tried so far.

      Comment

      • krishnaraj
        New Member
        • Dec 2007
        • 1

        #4
        This is the trigger

        CREATE TRIGGER your_trigger_na me
        ON Employee
        FOR INSERT AS
        BEGIN

        INSERT User (Name,Password)
        SELECT Name, Name + '123' FROM INSERTED
        END

        Substitute the column names if they are different in your table, Because there are some reserved words in these names

        Krishnaraj

        Comment

        • parshupooja
          New Member
          • Jun 2007
          • 159

          #5
          Thankssssssssss sssssssss


          Originally posted by krishnaraj
          This is the trigger

          CREATE TRIGGER your_trigger_na me
          ON Employee
          FOR INSERT AS
          BEGIN

          INSERT User (Name,Password)
          SELECT Name, Name + '123' FROM INSERTED
          END

          Substitute the column names if they are different in your table, Because there are some reserved words in these names

          Krishnaraj

          Comment

          • ck9663
            Recognized Expert Specialist
            • Jun 2007
            • 2878

            #6
            here's more about trigger

            -- ck

            Comment

            Working...