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).


Recommended Answers

select db_name()

Jump to Post

All 2 Replies

select db_name()
commented: It seems so obvious... +1

It seems so obvious looking at the function name.

Thanks for your help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.