Not sure if this is the proper sub-forum for this, but here goes. I have TST and PRD SQL servers. We refresh TST databases from PRD, so they're in sync as far as the objects they contain. The databases contain stored procs. Our Dev Team has a remote SQL server from which they can access TST and PRD. Dev Team can schedule SQL Agent jobs on their remote server. The jobs have operating system (CmdExec) steps which call SQLCMD which in turn calls a stored proc on remote TST or PRD server. Some stored procs on TST or PRD servers call sp_send_dbmail.
This seems to present two problems:
1. For any given SQL Agent job on the Dev Team's server, how do you tell the job step to alternatively run a stored proc hosted on TST vs PRD or vis versa?
2. How can the Dev Team manage stored procs on TST and PRD so TST sends test email to devguy@mycompany.com, but PRD sends emails to actual production recipients? I was thinking Dev guys might have to rewrite each of many existing stored procs to build in IF/THEN logic, or accept a parameter to detect what environment sp_send_dbmail is running in. Then pass in the parameter from the calling Agent job. Is there a better way?