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

SQL Server Auditing - Part 1 Expand / Collapse
Author
Message
Posted Sunday, July 25, 2004 10:04 PM


Keeper of the Duck

Keeper of the Duck

Group: Moderators
Last Login: Friday, September 26, 2014 7:52 AM
Points: 6,624, Visits: 1,873
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/bkelley/sqlserverauditingpart1.asp

K. Brian Kelley, CISA, MCSE, Security+, MVP - SQL Server
Regular Columnist (Security), SQLServerCentral.com
Author of Introduction to SQL Server: Basic Skills for Any SQL Server User
| Professional Development blog | Technical Blog | LinkedIn | Twitter
Post #128097
Posted Thursday, August 5, 2004 8:43 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, September 8, 2014 3:46 PM
Points: 165, Visits: 378
Excellent article - well done. I especially liked the screen prints with the red outline showing the important part of the display. I'm looking forward to Part Two...


Post #130377
Posted Thursday, August 5, 2004 10:02 AM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Wednesday, July 8, 2009 10:17 AM
Points: 727, Visits: 19

Not an hour before I read this article, I was staring at a script in query analyzer, trying to figure out how I was going to import the current SQL error log into my table.  The script has been staring back at me for a couple of days.   After reading this article, I'm back on track!  Thanks for a great article!

Steve




Post #130405
Posted Thursday, August 5, 2004 1:18 PM


Keeper of the Duck

Keeper of the Duck

Group: Moderators
Last Login: Friday, September 26, 2014 7:52 AM
Points: 6,624, Visits: 1,873
Glad that snippet of code was helpful.


K. Brian Kelley, CISA, MCSE, Security+, MVP - SQL Server
Regular Columnist (Security), SQLServerCentral.com
Author of Introduction to SQL Server: Basic Skills for Any SQL Server User
| Professional Development blog | Technical Blog | LinkedIn | Twitter
Post #130442
Posted Friday, August 5, 2005 4:12 PM


Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, February 10, 2014 8:41 PM
Points: 9, Visits: 83
Thank you -- well written.


Regards,

Mike
Post #208090
Posted Wednesday, November 30, 2005 1:56 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, July 29, 2009 10:04 AM
Points: 7, Visits: 2
Thank you for this article.  Very timely since I am right now creating a document that includes sql server auditing.
Post #240898
Posted Friday, June 1, 2007 12:43 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Tuesday, December 24, 2013 4:42 AM
Points: 460, Visits: 2,523

Very helpful information!



.
Post #370550
Posted Friday, June 1, 2007 2:09 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, May 23, 2008 1:51 AM
Points: 320, Visits: 8

Hi.

Only a little humble suggestion: to read/write configuration settings into the Windows Registry, Enterprise Manager uses xp_instance_regread and xp_instance_regwrite, that are the same as xp_regread and xp_regwrite, except already focused on the actual instance...

For those who want to SQL for the current instance, they are easier to use.

Note: You can profile (SQL Profiler) the activity of E.M.

Bye,

Daniele.




Post #370562
Posted Friday, June 1, 2007 9:48 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, June 29, 2007 2:30 AM
Points: 18, Visits: 1
Hi.

This is my first post to this forum, so please excuse me if I'm doing wrong.
And excuse my poor english, I am german.

First of all great thanks for your article. Been great help...
and sounding a good idea, so I added some more code and I'd ike to share the results with you.

1st: I used exactly the code provided in the article for creating the base table, only renaming the table from #errorlog to sk_errorlog according to our programming rules.

2nd: I built a second table as follows:

------------tbl-----------------

CREATE TABLE [sk_errorlog2] (
[rowID] [int] IDENTITY (1, 1) NOT NULL ,
[datum] [varchar] (10) COLLATE Latin1_General_CI_AS NULL , -- datum is german for date
[textRow] [varchar] (4000) COLLATE Latin1_General_CI_AS NULL ,
[uhrzeit] [varchar] (10) COLLATE Latin1_General_CI_AS NULL , -- uhrzeit is german for time
[kategorie] [varchar] (100) COLLATE Latin1_General_CI_AS NULL -- same for category
) ON [PRIMARY]
GO

--------------------------------

I will add colums like "servername" or similar later on when using it for multiple servers.
This table is meant to be a permanent depository for all sql-logs in my environment (only 5 sql-servers here)

3rd: I created some sp's for updating the second table
here is the first for inserting new rows:

----------------------SP1-----------------------
CREATE PROCEDURE [dbo].[sp_sk_errorlog]

AS

insert into sk_errorlog2 (textrow)
(
select

RTRIM(a.textrow) + COALESCE (b.textrow,'') as textrow

FROM
(
SELECT
*
FROM
sk_errorlog
WHERE
continuationrow=0
) as A

LEFT OUTER JOIN

(
SELECT
*
FROM
sk_errorlog
WHERE
continuationrow=1
) as B
ON
A.rowID = B.rowID - 1


where ( RTRIM(a.textrow) + COALESCE (b.textrow,'')
not in (select textrow from sk_errorlog2)
and a.continuationrow=0
)

)
GO
-------------------------------------------------------



the second sp will separate some values from the textrow:

-----------------sp2-------------------------
CREATE PROCEDURE [dbo].[sp_sk_errorlog_update]

AS
-----Check your collation/datetime settings here!-----
update sk_errorlog2 set datum =
(
select (case when (left (textrow,2) = '20') then left (textrow,10)
else null end)
)
,

uhrzeit =(
case ( right (left (textrow,12),1) )
when '0' then right ((left (textrow,19)),8)
when '1' then right ((left (textrow,19)),8)
when '2' then right ((left (textrow,19)),8)
else null
end
)
,
kategorie =(
case
----check for language settings here, e.g.: fehler is german for error!
----Here you can put the messages into categories, I started with the following
when textrow like '%[F,f]ehler%' or textrow like '[F,f]ehler%' then 'error'
when textrow like '%backup%' and textrow like '%datenbankprotokoll%' then 'protokoll'
when textrow like '%backup%' then 'backup'
when textrow like '%server%' then 'server'
when textrow like '%logon%' then 'logon'
else 'sonstiges'
end
)
where datum is null
----------------------------------------


/*
NOTE: the following 3 MS standard entries are the only ones without datetime information ( at least here

May 3 2005 23:18:38
Copyright (c) 1988-2003 Microsoft Corporation
Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 2)

*/


So now you should have some information in a better queryable form than directly from xp_readerrorlog.

Now use the gui you like best for creating some "management dashboard" where you can list the events separated by time and category.

Looking foward to part 2 and

Keep on coding!

SK
Post #370719
Posted Friday, June 1, 2007 11:02 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, May 9, 2012 10:26 AM
Points: 891, Visits: 1,958
Very cool, I definitely need to implement this. I have two servers that go through a ridiculous amount of logins every day, so this will be good to help monitor them more effectively.

I've also taken to forcing the error log to cycle every two weeks, syncing with our pay period. At 11:59pm Sunday night, I have a scheduled job that runs a sp_cycle_errorlog to keep the logs a bit more tidy.


Thanks!
Post #370748
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse