首頁  >  文章  >  資料庫  >  自动开始SQL的Agent代理

自动开始SQL的Agent代理

WBOY
WBOY原創
2016-06-07 14:54:441251瀏覽

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