Microsoft Exam Questions

Which Transact-SQL script should you execute?

You manage an instance of SQL Server 2008 named SQL1 . SQL1 has several jobs configured on it. The jobsteps in each job are configured to include the step output in the job history. You want to view the job history forall jobs and job steps that did not run successfully. Which Transact-SQL script should you execute?

A.
USE msdb; GO
EXEC dbo.sp_help_jobhistory @run_status = 0; GO

B.
USE msdb; GO
EXEC dbo.sp_help_jobhistory @run_status = 1; GO

C.
USE msdb; GO
EXEC dbo.sp_help_jobhistory @run_status = 2; GO

D.
USE msdb; GO
EXEC dbo.sp_help_jobhistory @run_status = 3; GO

Explanation:

You should run the following Transact-SQL script:
USE msdb; GO
EXEC dbo.sp_help_jobhistory
@run_status = 0; GO
The sp_help_jobhistory system stored procedure is used to view the history of jobs. If you do not specify aparticular job, the output contains the history of all jobs. The @run_status parameter displays jobs that have thespecified status. Specifying a value of 0 for the @run_status parameter returns history for all failed jobs. The history of jobs is stored in the SQL Server Agent job history log. To ensure that the output of a job step islogged in the job history log, you should select the Include step output in history check box on the Advanced page of the New Job Step dialog box. You can view the history of a job after you run the job. You should not run the following Transact-SQL script:
USE msdb; GO EXEC dbo.sp_help_jobhistory @run_status = 1; GO Specifying a value of 1 for the @run_status parameter returns history for all jobs that completed successfully. You should not run the following Transact-SQL script: USE msdb; GO EXEC dbo.sp_help_jobhistory @run_status = 2; GO Specifying a value of 2 for the @run_status
parameter returns history for all jobs steps that have a retry status. You should not run the following Transact-SQL script:
USE msdb; GO
EXEC dbo.sp_help_jobhistory @run_status = 3; GO
Specifying a value of 3 for the @run_status parameter returns history for all jobs that were canceled.

Objective:
Maintaining SQL Server Instances

Sub-Objective:
Manage SQL Server Agent jobs.

References:
MSDN > MSDN Library > Servers and Enterprise Development > SQL Server > SQL Server 2008 > ProductDocumentation > SQL Server 2008 Books Online > Database Engine > Technical Reference > Transact-SQLReference > System Stored Procedures (Transact-SQL) > SQL Server Agent Stored Procedures (Transact-SQL)> sp_help_jobhistory (Transact-SQL) MSDN > MSDN Library > Servers and Enterprise Development > SQL Server > SQL Server 2008 > ProductDocumentation > SQL Server 2008 Books Online > Database Engine > Operations > Administration > AutomatingAdministrative Tasks (SQL Server Agent) > Implementing Jobs > Viewing and Modifying Jobs