Query SQL Server error log from SQL

use master
go
declare @table table(logdate datetime,processinfo varchar(max),text varchar(max))
insert into @table exec xp_readerrorlog

select * from @table where processinfo like 'spid%' order by 1