• I don't advocate adding procedures to the Master database, but this will solve your issue.

    If you add a procedure to the Master database (and the dbo schema) and use a name starting with "sp_", it will be found when executing it from another database but run in the context of the database it is called from.

    For example:

    USE Master

    GO

    CREATE PROCEDURE dbo.sp_TestMe

    AS

    SELECT DB_Name()

    GO

    USE MyDatabase --Replace with your database name

    GO

    EXEC sp_TestMe