unable to read local eventlog(reason:参数不正确)

可能是sql agent服务在eventlog服务启动之前造成的,在网上找了很久,看到了一个解决方法,可以试一下。

转载地址:http://blogs.msdn.com/ialonso/archive/2007/12/13/sql-server-agent-failing-to-start-because-the-eventlog-service-has-not-been-started.aspx

 

use master
go
create proc spStartAgent as
-- Version 1.0 by JohannWe, EMEA GTSC, Microsoft customer support
set nocount on
declare @inst sysname, @cmd nvarchar(1000), @rc int, @msg nvarchar(1000)
set @msg=null
set @inst=convert(sysname, serverproperty('InstanceName'))
if @inst is null
    set @cmd=N'net start SQLServerAgent'
else
    set @cmd=N'net start SQLAgent$' + ltrim(rtrim(@inst))
create table #res (id tinyint not null identity, msg nvarchar(1000))
insert #res(msg) exec @rc=master.dbo.xp_cmdshell @cmd
if @rc=0
    return 0
else
if @rc=2
begin
select @msg=msg from #res where id=3 and msg like '%NET HELPMSG 2182%'
if @msg is not null -- we get error 2182, if SQLAgent was already started
    return 0
else
    begin
        raiserror ('An error was raised while starting SQLAgent. See System Event log for details!' , 19, @rc) with log
        return 1
    end
end
go
create proc spStartAgentDelay as
declare @t char(8), @rc int
set @t='00:01:00' -- Edit to change waiting time!
waitfor delay @t
exec @rc=spStartAgent
go
-- Register as startup proc:
declare @rc int
exec @rc=sp_procoption 'spStartAgentDelay', 'startup', 'on'
select ReturnCode=@rc
select IsStartup=objectproperty (object_id('spStartAgentDelay'), 'ExecIsStartup')
go

posted @ 2008-10-15 20:52 小米@ 阅读(...) 评论(...) 编辑 收藏