Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

xp_readerrorlog Expand / Collapse
Author
Message
Posted Tuesday, July 2, 2013 9:50 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, July 14, 2014 3:00 AM
Points: 2, Visits: 100
Hi, I'm trying to search a logfile with xp_readerrorlog for certain text but i would like to exclude databases starting with letter B for example. Does anyone know if this i possible with xp_readerrorlog?
Post #1469635
Posted Tuesday, July 2, 2013 10:06 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 1:22 PM
Points: 12,890, Visits: 31,849
xpreaderrorlog doesn't have a column dedicated to the database name, so no, there's no way to filter based on a LIKE statement directly.

there's a pretty good recap of the parameters and usage here:
[b]http://blog.sqltechie.com/2011/03/xpreaderrorlog-parameter-detail.html

i would simply stick all the results into a temp table, and then filter the results from there;
something like this looks right to me and my preliminary test:

[#RESULTS]
drop table[#RESULTS]
CREATE TABLE [dbo].[#RESULTS] (
[RESULTSID] INT IDENTITY(1,1) NOT NULL,
[LOGDATE] DATETIME NULL,
[PROCESSINFO] VARCHAR(128) NULL,
[XPTEXT] VARCHAR(max) NULL)

INSERT INTO #RESULTS([LOGDATE] ,[PROCESSINFO],[XPTEXT])
EXEC Xp_readerrorlog 0

SELECT DISTINCT #RESULTS.*
--dbz.*
FROM #RESULTS
left outer join(SELECT name from sys.databases where name like 'D%') dbz
ON CHARINDEX(dbz.name,#RESULTS.XPTEXT) = 0



Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1469644
Posted Wednesday, July 3, 2013 2:03 AM
Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: 2 days ago @ 5:22 AM
Points: 709, Visits: 1,412
Hi, I'm trying to search a logfile with xp_readerrorlog for certain text but i would like to exclude databases starting with letter B for example. Does anyone know if this i possible with xp_readerrorlog?


Are you trying to read a database transaction log, or the SQL Error Log? xp_readerrorlog is meant for reading the SQL Error Log.


Joie Andrew
"Since 1982"
Post #1469891
Posted Thursday, July 4, 2013 8:17 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, June 12, 2014 4:09 PM
Points: 4, Visits: 113
You can execute the below specifying the search string.

EXEC master.dbo.xp_readerrorlog 0, 1, N 'searchstring', NULL, NULL, NULL, N'asc'


Post #1470548
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse