Return database that a trigger was executed in

Please support our MS SQL advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Apr 2008
Posts: 58
Reputation: omrsafetyo is an unknown quantity at this point 
Solved Threads: 9
omrsafetyo omrsafetyo is offline Offline
Junior Poster in Training

Return database that a trigger was executed in

 
0
  #1
Nov 26th, 2008
I would like to create a variable in my trigger - @DBNAME.
When the trigger executes, this value should be set to the name of the database it was executed in.

E.g. for the master database the value of @DBNAME would be master.

How would I go about figuring out which database this was executed in? (This same trigger would be in place across multiple databases).

Thanks!
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,162
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 138
dickersonka dickersonka is offline Offline
Veteran Poster

Re: Return database that a trigger was executed in

 
1
  #2
Nov 28th, 2008
  1. SELECT db_name()
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 58
Reputation: omrsafetyo is an unknown quantity at this point 
Solved Threads: 9
omrsafetyo omrsafetyo is offline Offline
Junior Poster in Training

Re: Return database that a trigger was executed in

 
0
  #3
Nov 28th, 2008
It seems so obvious looking at the function name.

Thanks for your help!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for MS SQL
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC