question

Chris 2 avatar image
Chris 2 asked

catch sproc name in a trigger

Hi, Windows 2008 R2 and MS SQL 2012, is it possible to catch the procedure name which cause a table column updated from table trigger? Thanks. Chris
mssql2012
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Kev Riley avatar image
Kev Riley answered
Not simply. Take a look at the answers here: http://stackoverflow.com/questions/14467961/how-to-get-the-stored-procedure-name-from-a-trigger-when-an-update-operation-was Using DBCC INPUTBUFFER is a good attempt, but it can be wrong if you have nested procedure calls. And like Aaron points out in the comments, this is useful for hunting down bugs, but not really a recommended approach for using in everyday code!
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thanks for the hint. Indeed, last SQL command may not be the right one. Chris
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.