SQL Server Agent

  • Hi there,

    Just wanted some advice from u experts.

    We are currently using a script to check whether the SQL Server Agent is running in the morning. The scripts are as follows:

    1. EXEC master.dbo.xp_servicecontrol 'QueryState', 'SQLServerAgent'

    2. select * from sysprocesses where program_name like '%ref%'

    Script no.2 is frequently used by us but is not completely accurate. The output of this query is "SQL Agent Refresher". Sometimes the output would just be blank which means that the sql agent has stopped. Which is not always the case. After running script no.1, the output would say 'Running', which is an indication that the SQL Agent has not stopped.

    Do u guys have an automated process when doing this? What would be the best way to check whether the SQL Agent is running?

    Regards

    IC

  • One way of doing it is to pipe the output of net start to a text file and then examine the contents of that file. I'm not saying that this is the best way of doing it - it's just another option.

    John

  • Instead of using select * from sysprocesses where program_name like '%ref%', use if exists(select * from sysprocesses where program_name like '%SQLAgent%').........do something

    Chandrachurh Ghosh
    DBA – MS SQL Server
    Ericsson India Global Services Limited
    Quality is not an act, it is a habit.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply