Insert Trigger

  • I need a this to only insert if the problem_category = 'New User' and change the sub_type to 'Exchange'

    CREATE TRIGGER [HelpdeskNewUser] ON dbo.Helpdesk

    AFTER INSERT

    When (Problem_Category = 'New User')

    AS

    INSERT Helpdesk (Priority, NAMEL, NAMEF, NetName, PCSerial,

                                      Room, WD, Ring, NetworkPrinter_1, ZUSER, PIN, MMS, AMS,

                                      PH_NO, PH_EXT, Date_Recieved, Due_Date, Problem_Description,

                                      Problem_Category, CapersTktNum, Problem_Tech_Update,

                                      Problem_Update_Date, Closed, Date_Closed, Closed_By,

                                      Res_Code, Office, SPA, EmailFLG, Tech_Queue, Assigned_By,

                                      HDUser, Sub_Category)

    SELECT Priority, NAMEL, NAMEF, NetName, PCSerial, Room, WD, Ring, NetworkPrinter_1, ZUSER, PIN, MMS, AMS, PH_NO, PH_EXT, Date_Recieved, Due_Date, Problem_Description, Problem_Category, CapersTktNum, Problem_Tech_Update, Problem_Update_Date, Closed, Date_Closed, Closed_By, Res_Code, Office, SPA, EmailFLG, Tech_Queue, Assigned_By, HDUser, Sub_Category

    FROM Inserted i

  • I don't understand very well what you are trying to accomplish but this is shot in the dark

    CREATE TRIGGER [HelpdeskNewUser] ON dbo.Helpdesk

    AFTER INSERT

    AS

    if @@ROWCOUNT = 0

    return

    set nocount on

    INSERT Helpdesk (Priority, NAMEL, NAMEF, NetName, PCSerial,

                                      Room, WD, Ring, NetworkPrinter_1, ZUSER, PIN, MMS, AMS,

                                      PH_NO, PH_EXT, Date_Recieved, Due_Date, Problem_Description,

                                      Problem_Category, CapersTktNum, Problem_Tech_Update,

                                      Problem_Update_Date, Closed, Date_Closed, Closed_By,

                                      Res_Code, Office, SPA, EmailFLG, Tech_Queue, Assigned_By,

                                      HDUser, Sub_Category)

    SELECT Priority, NAMEL, NAMEF, NetName, PCSerial, Room, WD, Ring, NetworkPrinter_1, ZUSER, PIN, MMS, AMS, PH_NO, PH_EXT, Date_Recieved, Due_Date, Problem_Description, Problem_Category, CapersTktNum, Problem_Tech_Update, Problem_Update_Date, Closed, Date_Closed, Closed_By, Res_Code, Office, SPA, EmailFLG, Tech_Queue, Assigned_By, HDUser, Sub_category

    FROM Inserted i where Problem_Category = 'New User'

     don't know where "sub_type" goes either

     


    * Noel

  • That was it thank you so much!!!  the finished trigger is below:

    CREATE TRIGGER [HelpdeskNewUser] ON dbo.Helpdesk

    AFTER INSERT

    AS

    if @@ROWCOUNT = 0

    return

    set nocount on

    INSERT Helpdesk (Priority, NAMEL, NAMEF, NetName, PCSerial,

                                      Room, WD, Ring, NetworkPrinter_1, ZUSER, PIN, MMS, AMS,

                                      PH_NO, PH_EXT, Date_Recieved, Due_Date, Problem_Description,

                                      Problem_Category, CapersTktNum, Problem_Tech_Update,

                                      Problem_Update_Date, Closed, Date_Closed, Closed_By,

                                      Res_Code, Office, SPA, EmailFLG, Tech_Queue, Assigned_By,

                                      HDUser, Sub_Category)

    SELECT Priority, NAMEL, NAMEF, NetName, PCSerial, Room, WD, Ring, NetworkPrinter_1, ZUSER, PIN, MMS, AMS, PH_NO, PH_EXT, Date_Recieved, Due_Date, Problem_Description, Problem_Category, CapersTktNum, Problem_Tech_Update, Problem_Update_Date, Closed, Date_Closed, Closed_By, Res_Code, Office, SPA, EmailFLG, Tech_Queue, Assigned_By, HDUser, 'Exchange'

    FROM Inserted i where Problem_Category = 'New User' and Sub_Category = 'AS400 / NDDS / Domain'

     

     

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

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