??????. ????????????澯
???????????????????????????±????????????????????????????Gvim/UltraEdit /DOS????type errorlog?????Щ???????“???”????????????
????1. ?????????
????SQL Server????????2????????
????(1) ??????? (log viewer)??????????SQL Server ??SQL Server Agent?????????????????????????????????????????????????????????????ν?????????
????(2) δ?????????洢????xp_readerrorlog??????????????sp_readerrorlog??洢??????????xp_readerrorlog?????????????????4??????????????xp_readerrorlog?????
??????SQL Server 2000????????????????????????????????0~6??
exec dbo.xp_readerrorlog   --д0??null?????????????м???
exec dbo.xp_readerrorlog 1
exec dbo.xp_readerrorlog 6
--sql server 2000 read error log
if OBJECT_ID('tempdb..#tmp_error_log_all') is not null
drop table #tmp_error_log_all
create table #tmp_error_log_all
(
info varchar(8000)??--datetime + processinfo + text
num  int
)
insert into #tmp_error_log_all
exec dbo.xp_readerrorlog
--split error text
if OBJECT_ID('tempdb..#tmp_error_log_split') is not null
drop table #tmp_error_log_split
create table #tmp_error_log_split
(
logdate      datetime??--datetime
processinfo  varchar(100)??--processinfo
info         varchar(7900)--text
)
insert into #tmp_error_log_split
select CONVERT(DATETIME??LEFT(info??22)??120)??
LEFT(STUFF(info??1??23??'')??CHARINDEX(' '??STUFF(info??1??23??'')) - 1)??
LTRIM(STUFF(info??1??23 + CHARINDEX(' '??STUFF(info??1??23??''))??''))
from #tmp_error_log_all
where ISNUMERIC(LEFT(info??4)) = 1
and info <> '.'
and substring(info??11??1) = ' '
select *
from #tmp_error_log_split
where info like '%18456%'
??????SQL Server 2005?????汾???????7??????????????£?
????exec dbo.xp_readerrorlog 1??1??N'string1'??N'string2'??null??null??N'desc'
????????1.????????: 0 = ????? 1 = Archive #1?? 2 = Archive #2?? etc...
????????2.??????????:  1 or NULL = SQL Server ????????? 2 = SQL Agent ???????
????????3.?????????1: ???????????????
????????4.?????????2:  ??????????1??????????????????
????????5.?????????
????????6.??????????
????????7.???????: N'asc' = ???? N'desc' = ????
--sql server 2005 read error log
if OBJECT_ID('tempdb..#tmp_error_log') is not null
drop table #tmp_error_log
create table #tmp_error_log
(
logdate      datetime??
processinfo  varchar(100)??
info         varchar(8000)
)
insert into #tmp_error_log
exec dbo.xp_readerrorlog
select *
from #tmp_error_log
where info like '%18456%'
????2. ????????澯
??????????????Щ?????????????????(Error)??????(Warn)?????(Fail)????(Stop)???????и澯 (database mail)????????????24С????????????
declare
@start_time    datetime
??@end_time      datetime
set @start_time = CONVERT(char(10)??GETDATE() - 1??120)
set @end_time = GETDATE()
if OBJECT_ID('tempdb..#tmp_error_log') is not null
drop table #tmp_error_log
create table #tmp_error_log
(
logdate      datetime??
processinfo  varchar(100)??
info         varchar(8000)
)
insert into #tmp_error_log
exec dbo.xp_readerrorlog 0??1??NULL??NULL??@start_time??@end_time??N'desc'
select COUNT(1) as num?? MAX(logdate) as logdate??info
from #tmp_error_log
where (info like '%ERROR%'
or info like '%WARN%'
or info like '%FAIL%'
or info like '%STOP%')
and info not like '%CHECKDB%'
and info not like '%Registry startup parameters%'
and info not like '%Logging SQL Server messages in file%'
and info not like '%previous log for older entries%'
group by info
??????????????????????????kill?? dead?? victim?? cannot?? could?? not?? terminate?? bypass?? roll?? truncate?? upgrade?? recover?? IO requests taking longer than?????????и???????DBCC CHECKDB?????????н???б??????Error?????????£?
????DBCC CHECKDB (xxxx) executed by sqladmin found 0 errors and repaired 0 errors.
?????????0 errors????????????????0 errors??????澯??
????С??
?????????м??????????????????洢?????????????????????????????鼰?澯????????鵵????????????????????????2??????? ??
????(1) ??????????????
????(2) ??????????????????????????????????????????澯??
????(3) ?????????????鵵???????????????(2) ??????????step????????????