how to find the database context of the last sql statement?
The context of this script is my_database. It's just that the query references objects in a different database. Consider a scenario where a single query uses objects in multiple databases. Which database would you want returned?

What are you trying to accomplish?