当前位置:Gxlcms > mysql > 自动开始SQL的Agent代理

自动开始SQL的Agent代理

时间:2021-07-01 10:21:17 帮助过:37人阅读

自动开始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

人气教程排行