Re: SQL Server Agent thro' SP
From: Hari (hari_prasad_k_at_hotmail.com)
Date: 07/01/04
- Next message: Richard: "Server: Msg 946, Level 14, State 1, Line 1"
- Previous message: Italy: "Re: Same db not same result"
- In reply to: Shweta: "Re: SQL Server Agent thro' SP"
- Next in thread: Shweta: "Re: SQL Server Agent thro' SP"
- Reply: Shweta: "Re: SQL Server Agent thro' SP"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 1 Jul 2004 16:27:29 +0530
Hi Shweta,
The below was the procedure mentioned by Vyas. This procedure will check the
status of SQLAgent first and
insert the status to a temptable (#sqlstatus). If the status returned is
stopped then this procedure will
fire the start service to start the SQL Agent service.
the last line sp_procoption 'sp_autostartagent', 'startup', 'true' will set
the below procedure in startup. This will start the sql agent when sql
server starts.
----- procedure
use master
go
create proc sp_autostartagent
as
create table #sqlstatus(status nvarchar(20))
insert into #sqlstatus (status) exec master.dbo.xp_servicecontrol
'QUERYSTATE', 'SQLServerAgent'
if exists (select * from #sqlstatus where status='Stopped.')
exec xp_servicecontrol 'START', 'SQLServerAgent'
drop table #sqlstatus
go
exec sp_procoption 'sp_autostartagent', 'startup', 'true'
-- Thanks Hari MCDBA "Shweta" <Shweta@discussions.microsoft.com> wrote in message news:177149C4-C3B2-4BCE-8537-457A18AD542E@microsoft.com... > Thanks a lot, Narayana for your prompt reply. > I saw this XP in Master DB, but could not get any documentation @ it. Actually there are a few more undocumented extended stored procedures realted to Agent. Anyways, your post is a great help to me. > > Thanks again, > Shweta > > "Narayana Vyas Kondreddi" wrote: > > > You can use master.dbo.xp_servicecontrol, to query the state of SQLAgent and > > to start and stop it. For example: > > http://groups.google.com/groups?selm=udhB6NMKAHA.215%40cppssbbsa02.microsoft .com > > > > Note that this is undocumented. > > -- > > HTH, > > Vyas, MVP (SQL Server) > > http://vyaskn.tripod.com/ > > Is .NET important for a database professional? > > http://vyaskn.tripod.com/poll.htm > > > > > > "Shweta" <Shweta@discussions.microsoft.com> wrote in message > > news:E50CE3AD-83EA-4B1A-917B-55A12EA61B72@microsoft.com... > > Hi there, > > > > I have a requirement in which I need to check if SQL Server Agent Service is > > running. If it is not running, then I need to start the service using stored > > procedure. Since we have a SQL Server 2000, I can not use SQL-SCM API. > > > > The other option is to use Command line utility - sqlagent. But, it is > > independent of the Windows NT Service Control Manager & BOL says that use > > 'sqlagent' application for SQL Agent diagnosis purpose. So this option is > > also out. > > > > My last option is to use SQL DMO, create a application & use it. But before > > this I would like to know if there is any way to achieve this thro' SQL > > Server 2000 using SPs etc. > > > > Any help in this matter is welcome. > > > > Thanks in advance > > -Shweta > > > > > > > >
- Next message: Richard: "Server: Msg 946, Level 14, State 1, Line 1"
- Previous message: Italy: "Re: Same db not same result"
- In reply to: Shweta: "Re: SQL Server Agent thro' SP"
- Next in thread: Shweta: "Re: SQL Server Agent thro' SP"
- Reply: Shweta: "Re: SQL Server Agent thro' SP"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|