Results 1 to 4 of 4
  1. #1
    Join Date
    May 2008
    Posts
    2

    Unanswered: Getting primary key of the updated row in a table inside trigger

    Hi All,
    I am using a trigger. I want to get the data of a row before updating inside this trigger and insert it into a backup table. Please anybody help me. Example with code is highly appreciated.

    Thanks in advance.

  2. #2
    Join Date
    Jan 2004
    Location
    In a large office with bad lighting
    Posts
    1,040
    Show us what you have so far.

    -- This is all just a Figment of my Imagination --

  3. #3
    Join Date
    May 2008
    Posts
    2
    I am just starting. I am using COLUMNS_UPDATED function.

    CREATE TRIGGER [section_trigger]

    on [dbo].[cps_section]

    FOR UPDATE, DELETE

    AS

    print COLUMNS_UPDATED();


    But it is giving some HEX number. I don't no how to how to get the data of the updated row with this. Please help.

  4. #4
    Join Date
    Jan 2004
    Location
    In a large office with bad lighting
    Posts
    1,040
    It appears you need to do a little homework before we continue. Here is a good place to start:

    http://www.sqlteam.com/article/an-in...riggers-part-i

    COLUMNS_UPDATED () returns a bitmap of information read from LSB to MSB corresponding to the ascending ordinal position of a column in a table. I don't think you want to be using that for an insert or update trigger.

    Read the article, try again, and come back with the results.

    -- This is all just a Figment of my Imagination --

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •