Home All Groups Group Topic Archive Search About

view sql statement via trigger

Author
28 Jul 2005 10:00 PM
Bahman
Hello!

I have triggers that tell me when a table is updated, for example.

But I don't know what rows were appended. I don't know the content of the
sql statement that ran.

Is there a way to use the trigger to send me the actual sql statement that
was run?

-Bahman

Author
28 Jul 2005 10:22 PM
ML
Use the SQL Profiler to see what's going on 'behind the scenes'.

Start here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/architec/8_ar_aa_2xiq.asp


ML
Author
28 Jul 2005 10:54 PM
Bahman
Dear ML,

My problem is probably much simpler. I want to do this:

CREATE TRIGGER RankDataInsert
ON rank_data
FOR INSERT
AS
   EXEC master..sp_send_cdosysmail
'SqlSer***@hotmail.com',
'bahma***@hotmail.com',
'Insert Action', (select * from inserted)

But it bombs on 'select * from inserted'. Could there be a quick fix for this?

Show quote
"ML" wrote:

> Use the SQL Profiler to see what's going on 'behind the scenes'.
>
> Start here:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/architec/8_ar_aa_2xiq.asp
>
>
> ML
Author
29 Jul 2005 1:40 AM
ML
Yes. Declare a varchar variable and set the text of your query as its value.
Then supply the variable as the appropriate parameter.

And, most important of all: stop using sp_send_cdosysmail!!!

There's a much more efficient extended procedure xp_sendmail. This is the
21st century after all...


ML

AddThis Social Bookmark Button