Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Update Trigger in SQL 2000

  • 09-03-2009 01:16PM
    #1
    Registered Users, Registered Users 2 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: 52,142 ✭✭✭✭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, Registered Users 2 Posts: 224 ✭✭The Mighty Dubs


    Correct.Thats the variable i want to insert.


  • Moderators Posts: 52,142 ✭✭✭✭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