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 2005 Forums
 Transact-SQL (2005)
 Query text to get in insert/update/delete trigger

Author  Topic 

samwids
Starting Member

4 Posts

Posted - 2008-07-18 : 06:48:58
All,

I want to get the text of query that is just inserted/updated/delete (DML Statements). Query text that causes the trigger to fire.

For e.g. I have an after insert trigger trig1 on table table1
If insert query executed for table1 say "insert into table1 values ('AnyValue')" that will cause trig1 to fire. Inside that trigger I want to get the query text/insert statement that caused the trigger to fire.

How can I?



visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-18 : 06:52:27
didnt understand the purpose of such a requirement. Can you explain why you want it? just been curious..
Go to Top of Page

samwids
Starting Member

4 Posts

Posted - 2008-07-18 : 07:36:17
for auditing purpose, although there would be many approaches, but I want to go with it, is that possible?
quote:
Originally posted by visakh16

didnt understand the purpose of such a requirement. Can you explain why you want it? just been curious..

Go to Top of Page

samwids
Starting Member

4 Posts

Posted - 2008-07-21 : 01:50:40
Any SQL Guru?
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-07-21 : 23:06:36
Trace with profiler, or use third party's sql auditing tool.
Go to Top of Page

samwids
Starting Member

4 Posts

Posted - 2008-07-25 : 07:20:55
forbid but as far as I know, no one can run profiler withing trigger...........
simply the requirement is that "Inside that trigger I want to get the query text/insert statement that caused the trigger to fire.
"

quote:
Originally posted by rmiao

Trace with profiler, or use third party's sql auditing tool.

Go to Top of Page
   

- Advertisement -