Query the SQL Server Error Log |
|
Looking through the SQL error log can be kind of a beat down. Here is an easy way to query the error log. The number 0 after xp_readerrorlog returns the active error log. Increment that number to look through archived error logs.
if object_id('tempdb..#errorlog') is not null
drop table #errorlog
create table #errorlog
(logdate datetime2,
processinfo varchar(200),
ErrorText varchar(max))
insert into #errorlog
exec xp_readerrorlog 0
select * from #errorlog
Another option is using DBATools
docs.dbatools.io/Get-DbaErrorLog
if object_id('tempdb..#errorlog') is not null
drop table #errorlog
create table #errorlog
(logdate datetime2,
processinfo varchar(200),
ErrorText varchar(max))
insert into #errorlog
exec xp_readerrorlog 0
select * from #errorlog
Another option is using DBATools
docs.dbatools.io/Get-DbaErrorLog