how to monitor table changes

From: Ray Higdon (rayhigdon_at_higdonconsulting.com)
Date: 08/08/03


Date: Fri, 8 Aug 2003 03:10:10 -0700


Simple example:

create table foo (ikey int identity(1,1), name varchar(20))
create table foo2 (ikey int identity(1,1),foo_int int,
name varchar(20))

Create trigger mytrigg on foo
for insert,update,delete
as
insert into foo2
select * from inserted
union all
select * from deleted

insert into foo select 'joe' union all select 'rob' union
all select 'joey'
update foo set name = 'harry' where name = 'rob'
delete from foo where ikey > 1

select * from foo2

HTH

Ray Higdon MCSE, MCDBA, CCNA

>-----Original Message-----
>Hi ,
>I want to monitor insert,update,delete on a particular
code through trigger
>, I am planning to create a another table as a logtable ,
I can achieve it
>for update & delete can anybody give me code to achieve
all
>insert,update&delete using signle trigger .
>
>Thanks & Regards
>Ajay
>
>
>.
>



Relevant Pages

  • Re: User Functions in batch inserts
    ... Sorry for the late reply...Here is a quick example of instead of trigger... ... create table t(i int primary key, ... union all select 999,newid ... >>> newid()) ...
    (microsoft.public.sqlserver.programming)
  • Re: User Functions in batch inserts
    ... instead of trigger... ... >create table t(i int primary key, ... >union all select 999,newid ...
    (microsoft.public.sqlserver.programming)
  • mail relay
    ... foo and foo1 sit in office A, ... when foo sends mail to foo1, sendmail on G sees it as local mail ... When foo or foo1 wants to send it to foo2, I need my mail relay to ...
    (comp.mail.sendmail)
  • Re: Working with Nulls
    ... INSERT #foo SELECT ... UNION ALL SELECT '20090807' ... in certain situations in SQL Server. ... i don't know how nulls work. ...
    (microsoft.public.sqlserver.programming)
  • Synchronized objects
    ... On my client, i want to create a local instance of foo, ... instance of foo, foo2, which is a proxy to an instance on the server. ... entirely new component to have remoting work properly? ...
    (microsoft.public.dotnet.framework.remoting)

Loading