Is SqlServer Agent running?

Hi,

Can anyone give me some clues as to how I programmatically determine if Sql Server Agent is running. I'm using Sql 2005 and c#.

I have found the JobServer property in the SqlServer object but this still doesn't tell me is the service is running!!

Thanks for your help

Graham

[316 byte] By [Gravy] at [2008-1-2]
# 1

Take a look at Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer. This class has a ServiceCollection property which represents all SQL Server services on a target machine. Find your service and check it's state.

WBR, Evergray
--
Words mean nothing...
Evergray at 2007-9-13 > top of Msdn Tech,SQL Server,SQL Server SMO/DMO...
# 2

this is really a useful class. but do u know how to obtain the machine name from SQL server name?

cos in my application, the user just provoide server name. how can I get the machine name to configure the services on the machine?

tangy at 2007-9-13 > top of Msdn Tech,SQL Server,SQL Server SMO/DMO...
# 3

Server name is usually machine name (default instance) or machine_name\instance_name for named instances of SQL Server, so it's not a problem.

But anyway you can determine machine name using host_name() system function, if you're already connected to server.

WBR, Evergray
--
Words mean nothing...
Evergray at 2007-9-13 > top of Msdn Tech,SQL Server,SQL Server SMO/DMO...
# 4

yup. thanks for the reply.

I found that I can use SMO to find it machine name as well.

tangy at 2007-9-13 > top of Msdn Tech,SQL Server,SQL Server SMO/DMO...
# 5
how do you determine the machine name using objects in the SMO namespace?
dany0w at 2007-9-13 > top of Msdn Tech,SQL Server,SQL Server SMO/DMO...

SQL Server

Site Classified