title: Using MSDB stored procedures in application's database stored procedure
body: <p>This seems like it would be trivial, but I have not been able to come up with a solution to this small problem.</p>
  
  <p>I am attempting to create a stored procedure in my application's database. This stored procedure just executes a job that has been set up in the SSMS on the same server (seemed to be the only way to programmatically execute these jobs).</p>
  
  <p>The simple code is shown below:</p>
  
  <pre><code>USE ApplicationsDatabase
  GO
  CREATE PROCEDURE [dbo].[procedure]
  AS
  BEGIN
      EXEC dbo.sp_start_job N'Nightly Download'
  END
  </code></pre>
  
  <p>When ran as is, the procedure technically gets created but cannot be executed due to it not being able to find the 'sp_start_job' since it is using the ApplicationsDatabase. If I try to create the procedure again (after deleting previously created) but updating the USE to MSDB, it tries to add it to that system database for which I do not have permissions to do. Finally, I attempted to keep the original create statement but added the USE MSDB within the procedure (just to use the 'sp_start_job' procedure), but it would error saying USE statements cannot be placed within procedures.</p>
  
  <p>After pondering on the issue for a little (I'm obviously no SQL database expert), I could not come up with a solution and decided to solicit the advice of my peers. Any help would be greatly appreciated, thanks!</p>