Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

*I'm working as a senior database administrator for Total System Services Inc. I've more than a decade of IT experience in development, technical training, and database administration on Microsoft SQL Server platforms. I've authored numerous SQL Server technical articles and developed and implemented many successful database infrastructure, data warehouse and BI projects. I hold a master's degree in computer science from London Metropolitan University and industry standard certifications from Microsoft, Sun, Cisco, Brainbench, Prosoft and APM, including MCITP Database Administrator 2008, MCITP Database Administrator 2005, MCDBA SQL Server 2000 and MCTS .NET Framework 2.0 Web Applications.*
Browse by Tags · View All
Publications 25
SQL Server 2012 25
SSWUG 16
SQL Server 9
Performance Monitoring 8
SQL Server 2012 DMVs 7
SQL Server Builds 6
General Tips 5
Encryption 5
TechTarget 4

Archive · View All
July 2012 14
August 2012 12
October 2012 10
May 2013 9
April 2013 8
March 2013 7
February 2013 7
June 2012 7
December 2012 6
September 2012 6

Basit's SQL Server Tips

Find failed SQL Agent jobs using Transact-SQL script

Aug 15 2012 12:00AM by Basit Farooq   

Today, I’m sharing the following T-SQL script which you can use to find which SQL Server Agent Jobs failed yesterday. I use this script as part of my daily server monitoring SSIS package, which executes this script on all production SQL server and then sends email to our group:

SET NOCOUNT ON;

DECLARE @Value      [varchar](2048)
DECLARE @JobName  [varchar](2048)
DECLARE @PreviousDate [datetime]
DECLARE @Year   [varchar](4)
DECLARE @Month   [varchar](2)
DECLARE @MonthPre  [varchar](2)
DECLARE @Day   [varchar](2)
DECLARE @DayPre   [varchar](2)
DECLARE @FinalDate  [int]

-- Declaring Table variableDECLARE @FailedJobs TABLE ([JobName] [varchar](200))

-- Initialize VariablesSET @PreviousDate = DATEADD(dd, -1, GETDATE()) 
SET @Year = DATEPART(yyyy, @PreviousDate) 
SELECT @MonthPre = CONVERT([varchar](2), DATEPART(mm, @PreviousDate))
SELECT @Month = RIGHT(CONVERT([varchar], (@MonthPre + 1000000000)),2)
SELECT @DayPre = CONVERT([varchar](2), DATEPART(dd, @PreviousDate))
SELECT @Day = RIGHT(CONVERT([varchar], (@DayPre + 1000000000)),2)
SET @FinalDate = CAST(@Year + @Month + @DayAS [int])

INSERTINTO @FailedJobs

-- Final LogicSELECTDISTINCT j.[name]
FROM [msdb].[dbo].[sysjobhistory] h
INNERJOIN [msdb].[dbo].[sysjobs] j
 ON h.[job_id] = j.[job_id]
INNERJOIN [msdb].[dbo].[sysjobsteps] s
 ON j.[job_id] = s.[job_id]
  AND h.[step_id] = s.[step_id]
WHERE h.[run_status] = 0
 AND h.[run_date] > @FinalDate

SELECT @JobName = COALESCE(@JobName + ', ', '') + '['+ [JobName] + ']'FROM @FailedJobs

SELECT * FROM @FailedJobs

SELECT @Value = 'Failed SQL Agent job(s) found: '+ @JobName + '. 'IF @ValueISNULLBEGINSET @Value = 'None.'ENDSELECT @Value

I hope you will find this script useful ;)



Republished from Basit's SQL Server Tips [23 clicks].  Read the original version here [2 clicks].

Basit Farooq
414 · 0% · 95
2
 
0
Lifesaver
 
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

"Find failed SQL Agent jobs using Transact-SQL script" rated 5 out of 5 by 2 readers
Find failed SQL Agent jobs using Transact-SQL script , 5.0 out of 5 based on 2 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]