首页  >  文章  >  数据库  >  自动开始SQL的Agent代理

自动开始SQL的Agent代理

WBOY
WBOY原创
2016-06-07 14:54:441249浏览

自动开始SQL的Agent代理 Agent -- sp_sqlagent_autostart-- created by gertd@sqldev.net-- NOTE: works on NT/Win2K/WinXP only, not in Win9x--use mastergo if exists (select * from sysobjects where name = 'sp_sqlagent_autostart' and type = 'P') dr

自动开始SQL的Agent代理 Agent
-- sp_sqlagent_autostart
-- created by gertd@sqldev.net
-- NOTE: works on NT/Win2K/WinXP only, not in Win9x
--
use master
go 

if exists (select * from sysobjects where name = 'sp_sqlagent_autostart' and type = 'P')
    drop proc dbo.sp_sqlagent_autostart
go

create proc dbo.sp_sqlagent_autostart
as
set nocount on

declare @service nvarchar(128)

if (charindex(N'7.00', @@version, 0) > 0)
begin
    select @service = N'SQLServerAgent'
end

if (charindex(N'8.00', @@version, 0) > 0)
begin
    if (serverproperty('instancename') is null)
        select @service = N'SQLServerAgent'
    else
        select @service = N'SQLAgent$' + convert(nvarchar(128), serverproperty('InstanceName'))
end

exec master.dbo.xp_servicecontrol 'START', @service
go

exec master.dbo.sp_procoption 'sp_sqlagent_autostart', 'startup', 'true'
go
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn