Sql-server – Location of Jobs files in SQL Server

sql server

I have inherited a MS SQL 2008r2 machine.

This machine has about 20 jobs listed under:
Server -> SQL Server Agent -> Jobs

Before I touch this machine I want to back those jobs up in SVN so that I can track my changes.

I want to back it up to SVN because I want the source files to be in the same location as the other 30 repositories related to this company.

Where are these jobs physically located on the disk?

That is, where is the folder such that I can right click on it, choose copy, then go to the location where I am keeping the repository and paste it.

It does not matter: but this machine does not allows TortoiseSVN to be installed. I am not going to fight that, I am just going to copy the files and check them in on a different machine. This machine will be retired soon.

Checking them into SVN serves two purposes:
1. Allows me to see when the files change when I was not expecting.
2. Allows me to check out the source on a computer system that has more tools for searching and formatting.

Best Answer

Check msdb..jobs and msdb..jobsteps. As in the comment above if a step calls an external file you'll have to follow the path to get that file outside of the SQL Server. Here's some SQL to get you started, other columns may be meaningful to you.

Select j.name, j.enabled, j.description,
       js.step_id, js.step_name, js.subsystem, js.command
  From msdb.dbo.sysjobs j
 Inner Join msdb.dbo.sysjobsteps js On j.job_id = js.job_id
 Order By j.name, js.step_id