Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
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
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, June 30, 2016 2:07 AM
Points: 11, Visits: 165
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 @ 12:53 PM
Points: 14,433, Visits: 37,807
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

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
Post #1469644
Posted Wednesday, July 3, 2013 2:03 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Wednesday, July 13, 2016 1:00 PM
Points: 927, Visits: 1,855
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: Tuesday, February 9, 2016 3:25 PM
Points: 4, Visits: 124
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