Solved

Query SQL DTS sechduled Job History

Posted on 2004-09-12
3
567 Views
Last Modified: 2012-08-13
Is there a way of querying the MSDB database on SQL server for the history of a DTS sechduled Job.

What I would like to do is to query the database and get back if the job was suggestful or unSuggestful and how long it took to run the job.

I relise you can do this within steps in a dts job, but if the server is rebooted the dts job will not do this.

Can any one tell me which tables I need to query and the columns within that table.

Thanxs for Reading
0
Comment
Question by:GrahamR99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 13

Accepted Solution

by:
ispaleny earned 500 total points
ID: 12039063
mk:@MSITStore:C:\Program%20Files\Microsoft%20SQL%20Server\80\Tools\Books\tsqlref.chm::/ts_sys-j_42yh.htm
mk:@MSITStore:C:\Program%20Files\Microsoft%20SQL%20Server\80\Tools\Books\tsqlref.chm::/ts_sys-j_33w3.htm
mk:@MSITStore:C:\Program%20Files\Microsoft%20SQL%20Server\80\Tools\Books\tsqlref.chm::/ts_sys-j_15df.htm

select
B.job_id,originating_server,name,enabled,description,start_step_id,category_id
,owner_sid,notify_level_eventlog,notify_level_email,notify_level_netsend
,notify_level_page,notify_email_operator_id,notify_netsend_operator_id,notify_page_operator_id
,delete_level,date_created,date_modified,version_number
,instance_id,A.step_id
,A.step_name AS Hist_step_name
,sql_message_id,sql_severity,message
,case run_status when 1 then 'OK' when 0 then 'KO' end  run_status
,run_date,run_time
,run_duration
,operator_id_emailed,operator_id_netsent,operator_id_paged,retries_attempted
,A.server AS Hist_server
,C.step_name,subsystem,command
,flags,additional_parameters,cmdexec_success_code,on_success_action
,on_success_step_id,on_fail_action,on_fail_step_id
,C.server
,database_name
,database_user_name,retry_attempts,retry_interval,os_run_priority,output_file_name
,last_run_outcome,last_run_duration,last_run_retries,last_run_date,last_run_time
from sysjobhistory A
join sysjobs       B on A.job_id=B.job_id
join sysjobsteps   C on A.job_id=C.job_id and A.step_id=C.step_id
0
 
LVL 13

Expert Comment

by:ispaleny
ID: 12039083

create view viJobs as
select
B.job_id,originating_server,name,enabled,description,start_step_id,category_id
,owner_sid,notify_level_eventlog,notify_level_email,notify_level_netsend
,notify_level_page,notify_email_operator_id,notify_netsend_operator_id,notify_page_operator_id
,delete_level,date_created,date_modified,version_number
,instance_id,A.step_id
,A.step_name AS Hist_step_name
,sql_message_id,sql_severity,message
,case run_status when 1 then 'OK' when 0 then 'KO' end  run_status
,run_date,run_time
,run_duration
,operator_id_emailed,operator_id_netsent,operator_id_paged,retries_attempted
,A.server AS Hist_server
,C.step_name,subsystem,command
,flags,additional_parameters,cmdexec_success_code,on_success_action
,on_success_step_id,on_fail_action,on_fail_step_id
,C.server
,database_name
,database_user_name,retry_attempts,retry_interval,os_run_priority,output_file_name
,last_run_outcome,last_run_duration,last_run_retries,last_run_date,last_run_time
from sysjobhistory A
join sysjobs       B on A.job_id=B.job_id
join sysjobsteps   C on A.job_id=C.job_id and A.step_id=C.step_id
GO

select max(name) name,run_date,run_time,MIN(run_status) Status,SUM(run_duration) duration
from viJobs
group by job_id,run_date,run_time
0
 
LVL 13

Expert Comment

by:ispaleny
ID: 12039101
Or you can run

exec msdb..sp_help_job

to use more complicated job logic built in MS procedures (for last job run).
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question