Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Update Trigger in SQL 2000

Options
  • 09-03-2009 1:16pm
    #1
    Registered Users Posts: 224 ✭✭


    Hi, im having problems compiling a trigger. bacically i need the trigger to pull back a number that increments with each update. This is my poor attempt. Any suggestions are more than welcome.


    CREATE TRIGGER [UpdCloneItemCode] ON [dbo].[tblUnitMatrix]
    FOR UPDATE
    AS
    Declare @itemcode VARCHAR(50)
    If NOT UPDATE(ItemCode)
    Begin
    Return
    END
    Select CounterValue From tblCounter
    UPDATE tblCounter SET CounterValue=CounterValue+1


Comments

  • Moderators Posts: 51,799 ✭✭✭✭Delirium


    Hi, im having problems compiling a trigger. bacically i need the trigger to pull back a number that increments with each update. This is my poor attempt. Any suggestions are more than welcome.


    CREATE TRIGGER [UpdCloneItemCode] ON [dbo].[tblUnitMatrix]
    FOR UPDATE
    AS
    Declare @itemcode VARCHAR(50)
    If NOT UPDATE(ItemCode)
    Begin
    Return
    END
    Select CounterValue From tblCounter
    UPDATE tblCounter SET CounterValue=CounterValue+1

    Do you mean you want to use the variable outside the trigger?

    If you can read this, you're too close!



  • Registered Users Posts: 224 ✭✭The Mighty Dubs


    Correct.Thats the variable i want to insert.


  • Moderators Posts: 51,799 ✭✭✭✭Delirium


    Correct.Thats the variable i want to insert.
    Ok. You could just query the table that has the value after the insert.

    I'm not aware of a way to pass a variable out of a trigger. I've only a limited experience of SQL.

    If you can read this, you're too close!



Advertisement