INFORMATICS

The Best

Przełącznik języka

Zaproś mnie na KAWE

Jeżeli podoba Ci się strona i chcesz wspomóc projekt!

Postaw mi kawę na buycoffee.to

This Site

Płatnik

CMS

Hardware

Uncategorised

Emulators

Powershell

Storage Array

DNS

Antivirus program

Licznik

3.png0.png4.png0.png9.png3.png7.png
Today1041
Yesterday897
This week5819
This month15838
Total3040937

Visitor Info

  • IP: 3.129.216.15
  • Browser: Unknown
  • Browser Version:
  • Operating System: Unknown

Who Is Online

6
Online

czwartek, 21 listopad 2024 22:52

recreate agents jobs in MS SQL

Ocena użytkowników: 5 / 5

Gwiazdka aktywnaGwiazdka aktywnaGwiazdka aktywnaGwiazdka aktywnaGwiazdka aktywna
 

After the server failure, I lost access to the database copies and to the configured agents. How to recreate agents jobs.

Within the MSDB database, jobs are stored in a tables called dbo.sysjobs. This joins to a table called dbo.sysjobsteps that stores details of the individule steps. The schedules are stored in dbo.sysjobschedules and the History is stored in dbo.sysjobhistory.

MSDB will also contain other instance level objects such as alerts, operators and SSIS packages.

 

A script that shows us where and how SQL Server stores SQL jobs.

-- List of all the SQL Jobs on a server with steps
SELECT
     job.job_id,
     notify_level_email,
     name,
     enabled,
     description,
     step_name,
     command,
     server,
     database_name
FROM
    msdb.dbo.sysjobs job
INNER JOIN 
    msdb.dbo.sysjobsteps steps        
ON
    job.job_id = steps.job_id
WHERE 1=1
    --AND job.enabled = 1 -- uncomment this to see enabled SQL Jobs



and next example
also gets the category name and filters out the report server jobs.
SELECT  sysjobs.name 'Job Name',
        syscategories.name 'Category',
        CASE [description]
          WHEN 'No Description available.' THEN ''
          ELSE [description]
        END AS 'Description'
FROM    msdb.dbo.sysjobs
        INNER JOIN msdb.dbo.syscategories ON msdb.dbo.sysjobs.category_id = msdb.dbo.syscategories.category_id
WHERE   syscategories.name <> 'Report Server'
ORDER BY sysjobs.name 



Search