title: View the source for an sql server agent job?
body: <p>In SQL Management Studio, you can right click on an Agent Job and choose 'Script Job as' -> 'Create to/Drop to', which will reveal the backend code for the agent job.</p>
  
  <p>Is there a script I can execute which would generate this code as well?</p>
  
  <p>I've been searching for details on this, but all I can find so far is references for viewing the script via SQL Management Studio (<a href="https://social.msdn.microsoft.com/Forums/sqlserver/en-US/fdfc00d7-ea7b-4484-84d3-fa25f7b82b65/how-to-script-all-sql-jobs" rel="nofollow">Example 1</a>, <a href="https://technet.microsoft.com/en-us/library/ms191450(v=sql.105).aspx" rel="nofollow">Example 2</a>, <a href="https://www.toadworld.com/platforms/sql-server/b/weblog/archive/2013/03/18/how-to-create-scripts-for-all-selected-sql-server-agent-jobs" rel="nofollow">Example 3</a>).</p>
  
  <p>If anyone could point me in the proper direction containing ANY details on how to query for a creation script, that would be awesome.</p>