Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 729895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:51:00+00:00 2026-05-14T06:51:00+00:00

I am trying to use an update trigger in SQL Server 2000 so that

  • 0

I am trying to use an update trigger in SQL Server 2000 so that when an update occurs, I insert a row into a history table, so I retain all history on a table:

CREATE Trigger trUpdate_MyTable ON MyTable
FOR UPDATE
AS
    INSERT INTO
        [MyTableHistory]
        (
           [AuditType]
           ,[MyTable_ID]
           ,[Inserted]
           ,[LastUpdated]
           ,[LastUpdatedBy]
           ,[Vendor_ID]
           ,[FromLocation]
           ,[FromUnit]
           ,[FromAddress]
           ,[FromCity]
           ,[FromProvince]
           ,[FromContactNumber]
           ,[Comment])
    SELECT
        [AuditType] = 'U',
        D.*
    FROM
        deleted D
    JOIN    
        inserted I ON I.[ID] = D.[ID]

GO

Of course, I get an error

Cannot use text, ntext, or image columns in the ‘inserted’ and ‘deleted’ tables.

I tried joining to MyTable instead of deleted, but because the insert trigger fires after the insert, it ends up inserting the new record into the history table, when I want the original record.

How can I do this and still use text columns?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:51:00+00:00Added an answer on May 14, 2026 at 6:51 am

    the only way to do this is keep the current row in the history table too. Do what you tried and join to the actual table, and insert all columns from current actual table into the history table.

    you probably have something like this, where the history only has the previous version of a row:

    YourTable
    ID  value1   value2
    1   AAA      AAAA
    2   BBB      BBBB
    3   CCC      CCC3
    
    YourTableHostory
    HistoryID HistoryDate ID value1  value2
    1         4/17/2010   2  CCC     CCCC
    2         4/18/2010   2  CCC     CCC1
    

    I’m saying do something like this, where every version is stored:

    YourTable
    ID  value1   value2
    1   AAA      AAAA
    2   BBB      BBBB
    3   CCC      CCC3
    
    YourTableHostory
    HistoryID HistoryDate ID  value1  value2
    1         4/10/2010   1   AAA      AAAA
    2         4/10/2010   2   BBB      BBBB
    3         4/10/2010   3   CCC      CCCC
    4         4/17/2010   2   CCC      CCC1
    5         4/18/2010   2   CCC      CCC2
    5         4/19/2010   2   CCC      CCC3
    

    this way whenever there is an insert or update, just insert the current row into the history table, you have a duplicate of the current row, but that isn’t that terrible.

    If you are just adding this trigger to an existing table with data in it, then run a query like this to prepopulate all the current values for you:

    INSERT INTO YourTableHostory
            (HistoryDate,ID,value1,value2)
        SELECT
            GETDATE(),ID,value1,value2
            FROM YourTable
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 443k
  • Answers 443k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There is no such thing as WinForms for C, nothing… May 15, 2026 at 6:10 pm
  • Editorial Team
    Editorial Team added an answer If you're just using this same regex over and over… May 15, 2026 at 6:10 pm
  • Editorial Team
    Editorial Team added an answer Any time you run into a limitation with Apple's default… May 15, 2026 at 6:10 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.