Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Update Trigger - Capture Full Statement?

Author  Topic 

agdavidson
Starting Member

17 Posts

Posted - 2009-11-30 : 16:19:33
I'm trying to track down some mysterious changes in one of our tables and am at the point where I'd like to implement a trigger. However, I have very little experience with these and have only been able to capture the pre/post update values, update time and updating user... how do I capture the statement executed? Can I capture more like the source server/application, etc? Any help will be greatly appreciated!

Thanks,
Austin

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-11-30 : 16:43:44
What?
You're talking about UPDATE.
You say that you have the values before and after.
So why do you need the statement?
It is something like update table set column=<youKnowTheNewValue>...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-11-30 : 17:30:31
I think this is what you may need...

http://vyaskn.tripod.com/tracking_sql_statements_by_triggers.htm
Go to Top of Page

agdavidson
Starting Member

17 Posts

Posted - 2009-12-01 : 10:38:29
webfred - I need the statement because I'm trying to figure out what process is responsible for the update. I don't so much care about the values before and after. It's a status column whose value can be determined by inference from other tables... I can easily tell when the status is set incorrectly, so the data being wrong is not itself the real problem. I'm more concerned with finding out why these updates are happening and fixing the source.

vijayisonly - you're right... I think this is exactly what I need! I'll test it out today and post back with my findings.
Go to Top of Page

agdavidson
Starting Member

17 Posts

Posted - 2009-12-01 : 14:19:30
vijayisonly - Thank you so much! This is going to do the trick...
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-12-01 : 14:34:33
Np..ur welcome
Go to Top of Page
   

- Advertisement -