You could use sp_executesql
to dynamically call your nested Stored Procedure.
DECLARE @db AS SYSNAME
DECLARE @return_value AS INT
DECLARE @output_value AS INT
DECLARE @sql AS NVARCHAR(MAX)
-- Set your DB name
SET @db = N'mydb'
/*
Use sp_executesql to dynamically pass in the db and stored procedure
to execute while also defining the values and assigning to local variables.
*/
SET @sql = N'EXEC @rtn = ' + @db + '.dbo.[your_stored_procedure] @output OUTPUT'
EXEC sp_executesql @sql
, N'@rtn AS INT, @output AS INT OUTPUT'
, @return_value = @rtn
, @output_value = @output OUTPUT