Trigger on table has text column

  • I'd like to automatically save a copy of data into a historical table automatically if someone changed my data. I think of using trigger; however, the deleted and updated in trigger will not allow any text field.  Is there anyway to go over this? I'm really stuck. Please help.

    Thanks

    Minh

  • I think that the instead of triggers let you access those datatypes, but I have never done that so I could use a confirmation on this one.

  • You may copy data from static table, not from DELETED.

    INSERT INTO dbo.AuditTable (ID, Col1, TextCol)

    SELECT d.ID, D.Col1, T.TextCol

    FROM deleted D

    INNER JOIN dbo.MyTable T ON D.ID = T.ID

    But it must be INSTEAD OF trigger.

    _____________
    Code for TallyGenerator

  • Personally, I'd hunt down and shoot the bugger that put a Text column in the database in SQL Server 2000.

    Also, why the heck do you need to audit a Text column?  What are you storing in it? 

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

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

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