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!

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.