Search

Tuesday, April 30, 2013

TSQL command to check if SQL Agent services is started or down.

SET
NOCOUNT ON

DECLARE
@ISCOUNT varchar(100)

DECLARE
@ISCOUNT2 integer

BEGIN


SELECT @ISCOUNT2 = count(1)

FROM master.sys.sysprocesses

WHERE program_name like N'%SQLAgent%'

IF @ISCOUNT2 < 0

BEGIN

SET @ISCOUNT = convert(varchar(100),'FAILURE: SQL Server Agent service is NOT started!')

END

ELSE

BEGIN

SET @ISCOUNT = convert(varchar(100),'SQL Server Agent service is started.')

END

PRINT @ISCOUNT

END

GO

No comments:

Post a Comment