Friday, October 26, 2012

Best way to read error log

There are many ways to read error log from SQL Server.
  1. xp_readerrorlog
  2. SSMS->Management ->SQLServer Error Logs ->
in both the cases you need to wait untill it opens the error log and then either you need to scroll down/up for particular error or search for that particular error, both the cases it consumes some amount of time.

Lets take an example: To find out "Error: 1443, Severity: 16, State: 2"

the best way is: input the results of XP_readerrorlog to a temparory table once the result of the errorlog gets in to the temporary table you need to put a where condition to get the desired output.


create table #temp1
(logdate datetime,
processinfo varchar(100),
text_ varchar(1024)
)
insert #temp1exec xp_readerrorlog
select * from #temp1where text_ ='Error: 1443, Severity: 16, State: 2.'order by logdate asc

No comments:

Post a Comment