Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Microsoft SQL Server Error Log Scanning


Microsoft SQL Server Error Log Scanning

Author
Message
Sarab_SQLGeek
Sarab_SQLGeek
Old Hand
Old Hand (372 reputation)Old Hand (372 reputation)Old Hand (372 reputation)Old Hand (372 reputation)Old Hand (372 reputation)Old Hand (372 reputation)Old Hand (372 reputation)Old Hand (372 reputation)

Group: General Forum Members
Points: 372 Visits: 558
Great Article Rudy.

anyways people can also use XP_ReadErrorLog 0,1,'string_you_want_To_search'

like xp_readerrorlog 0,1,'error'
provided you are using SQL Server 2005+ versions


for earlier version this would be a good option.

Regards,
Sarabpreet Singh Cool
Sarabpreet.com
SQLChamp.com
Twitter: @Sarab_SQLGeek
Rudy Panigas
Rudy Panigas
SSC-Addicted
SSC-Addicted (440 reputation)SSC-Addicted (440 reputation)SSC-Addicted (440 reputation)SSC-Addicted (440 reputation)SSC-Addicted (440 reputation)SSC-Addicted (440 reputation)SSC-Addicted (440 reputation)SSC-Addicted (440 reputation)

Group: General Forum Members
Points: 440 Visits: 1303
Sarab. (2/15/2011)
Great Article Rudy.

anyways people can also use XP_ReadErrorLog 0,1,'string_you_want_To_search'

like xp_readerrorlog 0,1,'error'
provided you are using SQL Server 2005+ versions


for earlier version this would be a good option.


Thanks Sarab.

Nicely done. Your idea should make it easier to collect the data needed. Once we get rid of our SQL 2000 servers I will update my code.

Rudy



SQLRNNR
SQLRNNR
SSC-Insane
SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)SSC-Insane (21K reputation)

Group: General Forum Members
Points: 21091 Visits: 18259
Thanks for the helpful script.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

FairFunk
FairFunk
Valued Member
Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)

Group: General Forum Members
Points: 50 Visits: 1650
I just don’t understand....

From

CREATE TABLE [dbo].[ErrLogData](
[LogID] [int] IDENTITY(1,1) NOT NULL,
[LogDate] [datetime] NULL,
[ProcessInfo] [nvarchar](50) NULL,
[LogText] [nvarchar](4000) NULL,
[SQLServerName] [nvarchar](150) NULL,
PRIMARY KEY CLUSTERED
(
[LogID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

SET STATISTICS IO ON
GO

-- Remove older data
IF EXISTS (SELECT * FROM [ErrorLogStorage].[dbo].[ErrLogData])
BEGIN
TRUNCATE TABLE [ErrorLogStorage].[dbo].[ErrLogData]
END
DECLARE @SQLCmd VARCHAR(1024)
SELECT @SQLCmd = 'Insert Into [ErrorLogStorage].dbo.ErrLogData (LogDate, ProcessInfo, LogText) Exec master..xp_readerrorlog'
EXEC (@SQLCmd)

-- Cycle through the ErrLogData table and insert the server''s name
DECLARE SrvName_Cursor CURSOR FOR
SELECT [SQLServerName] FROM [ErrorLogStorage].[dbo].[ErrLogData] WHERE [SQLServerName] IS NULL
OPEN SrvName_Cursor
FETCH NEXT FROM SrvName_Cursor
WHILE @@FETCH_STATUS = 0
BEGIN
UPDATE [ErrorLogStorage].[dbo].[ErrLogData] SET [SQLServerName] = @@servername
FETCH NEXT FROM SrvName_Cursor
END
CLOSE SrvName_Cursor
DEALLOCATE SrvName_Cursor
GO

SET STATISTICS IO OFF
GO



Table 'ErrLogData'. Scan count 1, logical reads 2, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'ErrLogData'. Scan count 0, logical reads 225, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'Worktable'. Scan count 1, logical reads 232, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

Table 'Worktable'. Scan count 0, logical reads 2, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'ErrLogData'. Scan count 1, logical reads 2, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'ErrLogData'. Scan count 1, logical reads 32, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'ErrLogData'. Scan count 1, logical reads 9, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

To


SET STATISTICS IO ON
GO

-- Remove older data
IF EXISTS (SELECT * FROM [ErrorLogStorage].[dbo].[ErrLogData])
BEGIN

TRUNCATE TABLE [ErrorLogStorage].[dbo].[ErrLogData]

END

INSERT
INTO [ErrorLogStorage].dbo.ErrLogData
(
LogDate
,ProcessInfo
,LogText
)

EXEC master.dbo.xp_readerrorlog

UPDATE [ErrorLogStorage].[dbo].[ErrLogData]
SET [SQLServerName] = @@SERVERNAME


SET STATISTICS IO OFF
GO



Table 'ErrLogData'. Scan count 1, logical reads 2, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'ErrLogData'. Scan count 0, logical reads 225, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'Worktable'. Scan count 1, logical reads 232, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'ErrLogData'. Scan count 1, logical reads 32, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

Or



CREATE TABLE [dbo].[ErrLogData](
[LogID] [int] IDENTITY(1,1) NOT NULL,
[LogDate] [datetime] NULL,
[ProcessInfo] [nvarchar](50) NULL,
[LogText] [nvarchar](4000) NULL,
[SQLServerName] [nvarchar](150) DEFAULT(@@SERVERNAME) NOT NULL,
PRIMARY KEY CLUSTERED
(
[LogID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]


SET STATISTICS IO ON
GO

-- Remove older data
IF EXISTS (SELECT * FROM [ErrorLogStorage].[dbo].[ErrLogData])
BEGIN

TRUNCATE TABLE [ErrorLogStorage].[dbo].[ErrLogData]

END

INSERT
INTO [ErrorLogStorage].dbo.ErrLogData
(
LogDate
,ProcessInfo
,LogText
)

EXEC master.dbo.xp_readerrorlog

SET STATISTICS IO OFF
GO



Table 'ErrLogData'. Scan count 1, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'ErrLogData'. Scan count 0, logical reads 225, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'Worktable'. Scan count 1, logical reads 232, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.


?
Anthony peiris
Anthony peiris
Grasshopper
Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)

Group: General Forum Members
Points: 11 Visits: 117
Very helpful article.
One thing that I notice is that update of log table to include @@servername is not not necessary as the command xp_readerrorlog is always executed on the same server.
we can effectively use @@servername in the select clause

SELECT

,[LogID]
,[LogDate]
,[ProcessInfo]
,[LogText]
,SQLServerName=@@ServerName
FROM [ErrorLogStorage].[dbo].[ErrLogData]......
Phillip - Texas
Phillip - Texas
SSC Rookie
SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)SSC Rookie (31 reputation)

Group: General Forum Members
Points: 31 Visits: 162
Looks nice and easy. Great for an Implementation Engineer who is not a DBA, but would benefit from quickly checking the SQL Error Log if errors crop up during an implementation.
StoryWyoming
StoryWyoming
Grasshopper
Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)

Group: General Forum Members
Points: 16 Visits: 43
Good article. Updating the SQLServerName column could just as easily be updated in real-time through a default constraint:

CREATE TABLE [dbo].[ErrLogData](
[LogId] [int] IDENTITY(1,1) NOT NULL,
[LogDate] [datetime] NULL,
[ProcessInfo] [nvarchar](50) NULL,
[LogText] [nvarchar](4000) NULL,
[SQLServerName] [nvarchar](150) NOT NULL,
PRIMARY KEY CLUSTERED
(
[LogId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].ErrLogData] ADD CONSTRAINT [DF_dbo_ErrLogData_SQLServerName] DEFAULT (@@servername) FOR [SQLServerName]
GO

This way you could set up an SSIS job to loop through your more critical instances.


James E Bothamley
Sr DBA
Supreme Court of Wyoming
JBothamley@Courts.State.WY.US
JamesBothamley@Wyoming.Com

"Once in a while you can get shown the light
in the strangest of places if you look at it right"

JG 1942-1995 RIP

Youri S. Pikulin
Youri S. Pikulin
SSC-Enthusiastic
SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)

Group: General Forum Members
Points: 103 Visits: 797
Please pay attention: this stored procedure, xp_readerrorlog, can hang and you cannot kill it's process from SQL.
I am experimenting now with sp_readerrorlog.
sqldba.today
sqldba.today
Grasshopper
Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)

Group: General Forum Members
Points: 21 Visits: 616
That's true Youri, but I'm pretty sure that was fixed at some point in the 2005 and 2008 builds. Somewhere between SP3 and SP4 for 2005 if I remember correctly.
Youri S. Pikulin
Youri S. Pikulin
SSC-Enthusiastic
SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)SSC-Enthusiastic (103 reputation)

Group: General Forum Members
Points: 103 Visits: 797
Unfortunately, it has not been fixed... I don't have the global view, but I guess that this issue has not been fixed AT ALL.
I manage about 100 SQL Server instances from 2000 to 2012 and at the moment I get this problem with 2005 SP4 and 2008 SP1; earlier I had the same with other versions.

Even more bad information: such processes not only cannot be killed but also caused high CPU percentages. The only way to get rid of them is to restart SQL. But this is not always a good solution for production environments.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search