Re: Trigger
From: me (jscott56_at_teranews.com)
Date: 08/01/04
- Next message: me: "Re: Difference Between Truncate and Delete"
- Previous message: PEACEMAKER: "Re: can't see japanese/chinese character"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 1 Aug 2004 00:39:49 -0400
The usual way of doing this is to create a new table, having all the same
columns as the original, plus one more column that is a timestamp column.
On the primary key, if it is an identity column on the original, DONT also
make it an identity on the new table.
Name the new table with a name that is equal to the oriignal + 'History' or
something like that.
Ok, now create 2 triggers on the original table, base one on the Insert
event and the other the Update event.
The content of the insert trigger will be
Insert into abc_History(a,b,c,d,e)
Select * from inserted
The content of the insert trigger will be
Insert into abc_History(a,b,c,d,e)
Select * from deleted
that should do it.
Now, any time
"AQ Mahomed" <aq786@shoecrazy.co.za> wrote in message
news:%23pw32eWcEHA.2388@TK2MSFTNGP11.phx.gbl...
> Hi
>
> I need to record all changes to my current table automatically to a new
> table.
>
> Is this possible with a trigger.
>
> Many Thanks in advance
>
> AQ
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
- Next message: me: "Re: Difference Between Truncate and Delete"
- Previous message: PEACEMAKER: "Re: can't see japanese/chinese character"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|