Skip to the content
LeaplogicLeaplogic
  • Home
  • About Us
  • Contact
SIGN IN
  • Home
  • About Us
  • Contact

  • Getting Started
    • Before You Begin
    • Creating an Account
    • Logging into LeapLogic
    • Reset Password
    • Quick Tour of the Web Interface
    • LeapLogic in 15 minutes
      • Prerequisites
      • Step 1. Log into LeapLogic
      • Step 2. Create Assessment and Get Insights
      • Step 3. Create Transformation Pipeline and See Results
      • Step 4. Edit or Optimize the Transformed Code
      • Step 5: Complete the Transformation Lifecycle
  • Introduction to LeapLogic
    • Overview
    • High Level Architecture
    • Supported Legacy and Cloud Platforms
    • Key Features
  • Workload Assessment
    • Overview
    • Value Proposition
    • Creating Assessment
      • Prerequisites
      • Step 1. Provide Primary Inputs
        • Automation Coverage
      • Step 2. Add the Additional Inputs
        • Table Stat Extraction Steps
          • Teradata
          • Oracle
          • Netezza
      • Step 3. Update the Source Configuration
      • Step 4. Configure the Recommendation Settings
    • Assessment Listing
    • Understanding Insights and Recommendations
      • Volumetric Info
      • EDW
        • Oracle
          • Highlights
          • Analysis
          • Optimization
          • Lineage
          • Recommendations
          • Downloadable Reports
        • Vertica
          • Highlights
          • Analysis
          • Optimization
          • Lineage
          • Recommendations
          • Downloadable Reports
        • Snowflake
          • Highlights
          • Analysis
          • Optimization
          • Lineage
          • Recommendations
          • Downloadable Reports
        • Azure Synapse
          • Highlights
          • Analysis
          • Optimization
          • Lineage
          • Recommendations
          • Downloadable Reports
        • SQL Server
          • Highlights
          • Analysis
          • Optimization
          • Lineage
          • Recommendations
          • Downloadable Reports
        • Teradata
          • Highlights
          • Analysis
          • Optimization
          • Lineage
          • Recommendations
          • Downloadable Reports
        • Netezza
          • Highlights
          • Analysis
          • Optimization
          • Lineage
          • Recommendations
          • Downloadable Reports
        • Google Big Query
          • Highlights
          • Analysis
          • Optimization
          • Lineage
          • Recommendations
          • Downloadable Reports
        • Redshift
          • Highlights
          • Analysis
          • Optimization
          • Lineage
          • Recommendations
          • Downloadable Reports
        • PostgreSQL
          • Highlights
          • Analysis
          • Optimization
          • Lineage
          • Recommendations
          • Downloadable Reports
        • Duck DB
          • Highlights
          • Analysis
          • Optimization
          • Lineage
          • Recommendations
          • Downloadable Reports
        • ClickHouse
          • Highlights
          • Analysis
          • Optimization
          • Lineage
          • Recommendations
          • Downloadable Reports
        • Exasol
          • Highlights
          • Analysis
          • Optimization
          • Lineage
          • Recommendations
          • Downloadable Reports
        • DB2
          • Highlights
          • Analysis
          • Optimization
          • Recommendations
          • Lineage
          • Downloadable Reports
      • ETL
        • Informatica
          • Highlights
          • Analysis
          • Lineage
          • Downloadable Reports
        • Ab Initio
          • Highlights
          • Analysis
          • Lineage
          • Downloadable Reports
        • DataStage
          • Highlights
          • Analysis
          • Lineage
          • Downloadable Reports
        • Talend
          • Highlights
          • Analysis
          • Lineage
          • Downloadable Reports
        • SSIS
          • Highlights
          • Analysis
          • Lineage
          • Downloadable Reports
        • Informatica BDM
          • Highlights
          • Analysis
          • Lineage
          • Downloadable Reports
        • Oracle Data Integrator
          • Highlights
          • Analysis
          • Downloadable Reports
        • Pentaho
          • Highlights
          • Analysis
          • Downloadable Reports
        • Azure Data Factory
          • ARM Template
          • Highlights
          • Analysis
          • Downloadable Reports
        • Matillion
          • Highlights
          • Analysis
          • Downloadable Reports
        • SnapLogic
          • Highlights
          • Analysis
          • Downloadable Reports
      • Orchestration
        • AutoSys
          • Highlights
          • Analysis
          • Downloadable Reports
        • Control-M
          • Highlights
          • Analysis
          • Lineage
          • Downloadable Reports
        • SQL Server
          • Highlights
          • Analysis
      • BI
        • OBIEE
          • Highlights
          • Analysis
          • Lineage
          • Downloadable Reports
        • Tableau
          • Highlights
          • Analysis
          • Lineage
          • Downloadable Reports
        • IBM Cognos
          • Highlights
          • Analysis
          • Downloadable Reports
        • MicroStrategy
          • Highlights
          • Analysis
          • Lineage
          • Downloadable Reports
        • Power BI
          • Highlights
          • Analysis
          • Lineage
          • Downloadable Reports
        • SSRS
          • Highlights
          • Analysis
          • Downloadable Reports
        • SAP BO
          • Highlights
          • Analysis
          • Lineage
          • Downloadable Reports
        • WebFOCUS
          • Highlights
          • Analysis
          • Downloadable Reports
      • Analytics
        • SAS
          • Highlight
          • Analysis
          • Lineage
          • Downloadable Reports
        • Alteryx
          • Highlights
          • Analysis
          • Lineage
          • Downloadable Reports
      • Integrated Assessment (EDW, ETL, Orchestration, BI)
        • Highlights
        • Analysis
        • Optimization
        • Lineage
        • Recommendations
    • Managing Assessment Reports
      • Downloading Report
      • Input Report Utility
      • View Configuration
    • Complexity Calculation Logic
    • Key Benefits
    • Ad hoc Query
  • Metadata Management
    • Overview
    • Introduction to Data Catalog
      • Managing Data Catalog
        • Building Data Catalog
        • Insights to Data Catalog
        • Managing the Repository and Data Source
      • Creating Repository (Repo)
      • Creating Data Source
    • Tag Management
    • Key benefits
  • Batch Processing using Pipeline
    • Introduction
    • Designing Pipeline
      • How to create a pipeline
        • Configuring Migration Stage
          • Schema Optimization
        • Configuring Transformation Stage
          • On-premises to Cloud
          • Cloud-to-Cloud
          • LeapLogic Express
        • Configuring Validation Stage
          • Data Validation
            • Table
            • File
            • File and Table
            • Cell-by-cell validation
          • Query Validation
            • Query Validation (When Data is Available)
            • Query Validation (When Data is Not Available)
          • Schema Validation
        • Configuring Execution Stage
        • Configuring ETL Conversion Stage
          • Ab Initio
          • Informatica
          • Informatica BDM
          • Matillion
          • DataStage
          • SSIS
          • IICS
          • Talend
          • Oracle Data Integrator
          • Pentaho
          • SnapLogic
        • Configuring Mainframe Conversion Stage
          • Cobol
          • JCL
        • Configuring Orchestration Stage
          • AutoSys
          • Control-M
        • Configuring BI Conversion Stage
          • OBIEE to Power BI
          • OBIEE to AWS QuickSight
          • Tableau to Amazon QuickSight
          • Tableau to Power BI
          • Tableau to Superset
          • Tableau to Looker
          • IBM Cognos to Power BI
        • Configuring Analytics Conversion Stage
          • SAS
          • Alteryx
        • Configuring Script Conversion Stage
    • Key Features
      • How to schedule a pipeline
      • Configuring Parameters
  • Pipeline Reports
    • Overview of Pipeline Report
    • Pipeline Listing
    • Reports and Insights
      • Migration
      • Transformation
        • On-premises to Cloud
        • Cloud-to-Cloud
        • LeapLogic Express
      • Validation
        • Data
          • File
          • Table
          • File and Table
        • Query
          • Query Validation Report (When Data is Available)
          • Query Validation Report (When Data is not Available)
        • Schema
      • Execution
      • ETL
        • Ab Initio
        • Informatica
        • Informatica BDM
        • Matillion
        • DataStage
        • SSIS
        • IICS
        • Talend
        • Oracle Data Integrator
        • Pentaho
        • SnapLogic
      • Mainframe
        • Cobol
        • JCL
      • Orchestration
        • AutoSys
        • Control-M
      • BI
        • OBIEE to Power BI
        • OBIEE to Amazon QuickSight
        • Tableau to Amazon QuickSight
        • Tableau to Power BI
        • Tableau to Superset
        • Tableau to Looker
        • IBM Cognos to Power BI
      • Analytics
        • SAS
        • Alteryx
      • Shell Script
      • Common Model
    • Automation Level Indicator
      • ETL
        • Informatica
        • Matillion
        • DataStage
        • Informatica BDM
        • SnapLogic
        • IICS
        • Ab Initio
        • SSIS
        • Talend
        • Pentaho
      • Orchestration
        • AutoSys
        • Control-M
      • EDW
      • Analytics
        • SAS
        • Alteryx
      • BI
      • Shell Script
    • Error Specifications & Troubleshooting
  • SQL Transformation
    • Overview
    • Creating and Executing the Online Notebook
      • How to Create and Execute the Notebook
      • Supported Features
    • Configuring the Notebook
      • Transformation
      • Unit Level Validation
      • Script Level Validation
    • Notebook Listing
  • Operationalization
    • Overview
      • Basic
      • Advanced
      • Cron Expression
    • Parallel Run Pipeline Listing
  • Transformation Source
    • Introduction
    • Creating Transformation Source Type
  • Governance
    • Summary of Governance - Roles and Permissions
    • User Creation
      • Creating a new User Account
    • Adding Roles and permissions
      • How to add Roles and Permissions to a new user?
    • Adding Group Accounts
    • Default Quota Limits
    • Product Usage Metrics
  • License
    • EDW
    • ETL
  • Script/ Query Log/ Code Extraction Prerequisites
    • Cloud
      • Aurora PostgreSQL
      • Azure Data Factory
      • Snowflake
      • Azure Synapse
      • Google BigQuery
      • Redshift
      • Azure SQL Database Hyperscale
    • EDW
      • Oracle
      • Netezza
      • Teradata
      • Vertica
      • SQL Server
      • DB2
      • MySQL
      • PostgreSQL
    • ETL
      • DataStage
      • Informatica
      • SSIS
      • Talend
      • TAC
      • ODI
      • IICS
      • DBT
      • Pentaho
      • Matillion
      • SnapLogic
      • Ab Initio
      • SAP BODS
      • Talend
      • WebFOCUS
    • BI
      • Cognos
      • OBIEE
      • Tableau
      • Metabase
      • MicroStrategy
      • PowerBI
      • SAP BO Metadata Extraction
      • SAP BO Universe and Web Intelligence Reports Extraction
      • SSRS
    • Analytics
      • SAS
      • Alteryx
    • Orchestration
      • Autosys
      • Control-M
      • SQL Server
    • Mainframe
  • LeapLogic Desktop Version
    • Overview
    • Registration and Installation
    • Getting Started
    • Creating Assessment
      • ETL
      • DML
      • Procedure
      • Analytics
      • Hadoop
    • Reports and Insights
      • Downloadable Reports
      • Reports for Estimation
    • Logging and Troubleshooting
    • Sample Scripts
    • Desktop vs. Web Version
    • Getting Help
  • LeapLogic (Version 4.7) Deployment
    • System Requirements
    • Prerequisites
    • Deployment
      • Extracting Package
      • Placing License Key
      • Executing Deployment Script
      • Accessing LeapLogic
    • Uploading License
    • Appendix
    • Getting Help
  • Removed Features
    • Configuring File Validation Stage
    • Variable Extractor Stage
      • Variable Extractor Report
    • Configuring Meta Diff Stage
      • Meta Diff
    • Configuring Data Load Stage
      • Data Load
    • Configuring Multi Algo Stage
  • FAQs
  • Tutorial Videos
  • Notice
Home   »  Script/ Query Log/ Code Extraction Prerequisites   »  Orchestration  »  SQL Server Agent Job and Execution Logs Extraction Prerequisites

SQL Server Agent Job and Execution Logs Extraction Prerequisites

This topic briefs about the SQL Server agent job and execution logs extraction prerequisites.

In This Topic:

  • Introduction
  • SQL Server Agent Job Extraction
  • SQL Server Agent Job Execution History
  • Getting Help


Introduction

LeapLogic’s Assessment profiles existing inventory, identifies complexity, performs dependency analysis, and provides recommendations for migration to the modern data platform.


SQL Server Agent Job Extraction

LeapLogic requires SQL Server agent jobs exported in .sql or .txt format which typically contains information about all the steps, jobs etc. Follow the below given steps to start exporting the jobs using the SQL Server Management Studio 9SSMS.

Bulk Export

For exporting multiple SQL Server agent jobs at a time, please follow the below steps.

  1. Open SQL Server Management Studio.
  2. Expand SQL Server Agent and expand Jobs.
  3. Hit the F7 key on your keyboard to open the Object Explorer Details.
  4. Select all the jobs you want to export.
  5. Right-click the highlighted jobs then select Script Job as.
  6. Select CREATE To, then select File to select a destination for the scripts. Typically, the destination is a file with a .sql extension.

Single Job Export

For exporting a single SQL Server agent job at a time, please follow the below steps.

  1. Open SQL Server Management Studio.
  2. Expand SQL Server Agent and then Jobs.
  3. Right-click the job you want to create a backup script for, and then select Script Job as.
  4. Select CREATE To, then select File to select a destination for the script. Typically, the destination is a file with a .sql extension.
  5. Repeat this procedure from Step 3 for each job you want to export.


SQL Server Agent Job Execution History

To export the execution history of SQL Server Agent jobs, please run the following query and save the results to a flat file.

Note:

Make sure to update the highlighted date range to export the required job execution logs.

DECLARE @start_date date = ‘2024-10-01’

DECLARE @end_date date = ‘2024-10-23’

SELECT DISTINCT

S.job_id

,s.subsystem

,s.database_name AS [Database]

,J.name

,CAST(S.command AS NVARCHAR(MAX)) as Command

,J.enabled

,CASE WHEN SD.step_id IS NULL AND (S.on_success_action=1 or S.on_success_action=2) then ‘INDEPENDENT’

                WHEN SD.step_id IS NOT NULL and (SD.on_success_action=3 or SD.on_success_action=4) THEN ‘DEPENDS ON :’+CAST(SD.step_id as VARCHAR)

                ELSE ‘INDEPENDENT’

                END as DEPENDeNCY

,S.step_id

,S.step_name

,H.run_date

,H.run_time

,H.run_duration

,((H.run_duration/10000*3600 + (H.run_duration/100)%100*60 + H.run_duration%100 + 31 ) / 60)

          as ‘RunDurationMinutes’

,CONVERT(VARCHAR(16), J.date_created, 120) date_created

,CONVERT(VARCHAR(16), J.date_modified,120) date_modified

,LEFT(CAST(s.last_run_date AS VARCHAR),4)+ ‘-‘

+SUBSTRING(CAST(s.last_run_date AS VARCHAR),5,2)+’-‘

+SUBSTRING(CAST(s.last_run_date AS VARCHAR),7,2) last_run_date

,CASE

 WHEN LEN(CAST(S.last_run_time AS VARCHAR)) = 6 

  THEN SUBSTRING(CAST(S.last_run_time AS VARCHAR),1,2)

    +’:’ + SUBSTRING(CAST(S.last_run_time AS VARCHAR),3,2)

    +’:’ + SUBSTRING(CAST(S.last_run_time AS VARCHAR),5,2)

WHEN LEN(CAST(S.last_run_time AS VARCHAR)) = 5

  THEN ‘0’ + SUBSTRING(CAST(S.last_run_time AS VARCHAR),1,1)

    +’:’+SUBSTRING(CAST(S.last_run_time AS VARCHAR),2,2)

    +’:’+SUBSTRING(CAST(S.last_run_time AS VARCHAR),4,2)

WHEN LEN(CAST(S.last_run_time AS VARCHAR)) = 4

  THEN ’00:’

    + SUBSTRING(CAST(S.last_run_time AS VARCHAR),1,2)

    +’:’ + SUBSTRING(CAST(S.last_run_time AS VARCHAR),3,2)

WHEN LEN(CAST(S.last_run_time AS VARCHAR)) = 3

  THEN ’00:’

    +’0′ + SUBSTRING(CAST(S.last_run_time AS VARCHAR),1,1)

    +’:’ + SUBSTRING(CAST(S.last_run_time AS VARCHAR),2,2)

WHEN LEN(CAST(S.last_run_time AS VARCHAR)) = 2  THEN ’00:00:’ + CAST(S.last_run_time AS VARCHAR)

WHEN LEN(CAST(S.last_run_time AS VARCHAR)) = 1  THEN ’00:00:’ + ‘0’+ CAST(S.last_run_time AS VARCHAR)

END last_run_time

,CAST(SC.next_scheduled_run_date AS DATE) next_run_date

,convert(char(5), SC.next_scheduled_run_date, 108) as next_run_time

,CASE WHEN freq_type=1 THEN ‘One time only’

                WHEN freq_type=2 THEN ‘Daily’

                WHEN freq_type=8 THEN ‘Weekly’

                WHEN freq_type=16 THEN ‘Monthly’

                WHEN freq_type=32 THEN ‘Monthly, relative to freq_interval’

                WHEN freq_type=64 THEN ‘Runs when the SQL Server Agent service starts’

                WHEN freq_type=128 THEN ‘Runs when the computer is idle’

                ELSE ”

                END AS Frequency

,CASE WHEN freq_type =1 THEN ‘Sunday’

                WHEN freq_type =2 THEN ‘Monday’

                WHEN freq_type =3 THEN ‘Tuesday’

                WHEN freq_type =4 THEN ‘Wednesday’

                WHEN freq_type =5 THEN ‘Thursday’

                WHEN freq_type =6 THEN ‘Friday’

                WHEN freq_type =7 THEN ‘Saturday’

                WHEN freq_type =8 THEN ‘Day’

                WHEN freq_type =9 THEN ‘Weekday’

                WHEN freq_type =10 THEN ‘Weekend day’

                ELSE ”

                END AS InterValType

FROM msdb.dbo.sysjobsteps AS S

INNER JOIN msdb.dbo.sysjobs as J

ON S.job_id = J.job_id

INNER JOIN msdb.dbo.sysjobhistory H

ON S.job_id = H.job_id

INNER JOIN

(SELECT job_id,MIN(next_scheduled_run_date) as next_scheduled_run_date FROM

msdb.dbo.sysjobactivity

GROUP BY job_id

) AS SC

ON J.job_id = SC.job_id

LEFT JOIN msdb.dbo.sysjobsteps AS SD

ON S.job_id = SD.job_id

and S.step_id-1 = SD.step_id

LEFT JOIN msdb.dbo.sysjobschedules AS JS on J.job_id = JS.job_id

LEFT join msdb.dbo.sysschedules AS SS on JS.schedule_id = SS.schedule_id

Where convert(date,convert(varchar(8),H.run_date),101)

BETWEEN @start_date and @end_date  – – Change for date range queries

– – and LEFT(j.name,1) NOT IN (‘1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9′,’0’)

and CHARINDEX(‘-‘,j.name) = 0

and j.name <> ‘syspolicy_purge_history’ ORDER BY S.job_id, S.step_id;


Getting Help

Contact LeapLogic technical support at info@leaplogic.io


To learn more, contact our support team or write to: info@leaplogic.io

Copyright © 2025 Impetus Technologies Inc. All Rights Reserved

  • Terms of Use
  • Privacy Policy
  • License Agreement
To the top ↑ Up ↑