How to track old values

  • Hi,

    create table dbo.example

    (

    num int

    ,name varchar(10)

    ,age int

    ,sal float

    )

    insert into dbo.example

    select 1,'fff',24,10000 union all

    select 2,'ggg',25,20000 union all

    select 3,'hhh',26,30000 union all

    select 4,'jjj',27,40000

    go

    create view dbo.vw_example with schemabinding

    as

    select

    num

    ,name

    ,age

    ,sal

    from dbo.example

    go

    -- updating one field

    update dbo.example

    set name='zzz'

    where num=1

    requirement:

    when any field from table gets update

    I need to select

    with entire row with old value and

    with entire row with new value

    as below.....

    status num name sal

    old 1fff2410000

    new 1zzz2410000

    can i guide me how can i track old value...

    actual requirement is one view depends on 10+ tables.

    any filed from any table gets update from front end application .

    when i run that view I need show with entire row old value and with entire row with new value

    can I go for triggers on views.

  • In SS2K5 you could use a trigger and insert the the data of the internal tables INSERTED and DELETED into an audit table.

    Your view would be based on the 10 audit tables.



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • You might find this useful

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

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