Monitoring db activity/usage in SQL Server 2005

Get help on databases - MySQL, Oracle, Access, etc.
Post Reply
ArmatageShanks
Registered User
Posts: 636
Joined: 01 Feb 2006, 02:00
Location: Cape Town

Monitoring db activity/usage in SQL Server 2005

Post by ArmatageShanks »

Is it possible to find out
a) how often, and
b) when last
a sql server 2005 database is/was accessed?

I need to write a script that will determine which dbs are being used and which have just been lying dormant.
xchuckx has been flushed and respawned neo-nymbo
User avatar
hamin_aus
Forum Moderator
Posts: 18363
Joined: 28 Aug 2003, 02:00
Processor: Intel i7 3770K
Motherboard: GA-Z77X-UP4 TH
Graphics card: Galax GTX1080
Memory: 32GB G.Skill Ripjaws
Location: Where beer does flow and men chunder
Contact:

Re: Monitoring db activity/usage in SQL Server 2005

Post by hamin_aus »

Quick and dirty solution would be to use SQL Server Profiler to run a trace to do this.

You can filter the Audit Login, DatabaseName and Application events plus anything else you may think you need, you weren't very specific...

Let the trace run for a day or a week - whatever you want.
Save it to some table somewhere that you can run custom queries on afterwards to see how often each DB was accesses etc etc.

Thats what I'd do off the top of my head, I'm sure there is a better way to do it than a trace, but this should be the quickest.
Image
User avatar
Ron2K
Forum Technical Administrator
Posts: 9050
Joined: 04 Jul 2006, 16:45
Location: Upper Hutt, New Zealand
Contact:

Re: Monitoring db activity/usage in SQL Server 2005

Post by Ron2K »

Running a trace is pretty much the only way I know how to do this. :wink:
Kia kaha, Kia māia, Kia manawanui.
ArmatageShanks
Registered User
Posts: 636
Joined: 01 Feb 2006, 02:00
Location: Cape Town

Re: Monitoring db activity/usage in SQL Server 2005

Post by ArmatageShanks »

Ok thanks; will look more into that.
xchuckx has been flushed and respawned neo-nymbo
ArmatageShanks
Registered User
Posts: 636
Joined: 01 Feb 2006, 02:00
Location: Cape Town

Re: Monitoring db activity/usage in SQL Server 2005

Post by ArmatageShanks »

Ok, so I've started playing around with the profiler. What would be the best event to trace to monitor db activity? I was thinking perhaps SQL:BatchCompleted, because it records all queries made to all db's on a server; but letting it run for a week or two could result in a very big saved file/table indeed.
xchuckx has been flushed and respawned neo-nymbo
User avatar
hamin_aus
Forum Moderator
Posts: 18363
Joined: 28 Aug 2003, 02:00
Processor: Intel i7 3770K
Motherboard: GA-Z77X-UP4 TH
Graphics card: Galax GTX1080
Memory: 32GB G.Skill Ripjaws
Location: Where beer does flow and men chunder
Contact:

Re: Monitoring db activity/usage in SQL Server 2005

Post by hamin_aus »

Do you want to record unique accesses like logins, or do you want to know every time a db is accessed for a query or some other call - even if that is multiple times by the same login?
Image
ArmatageShanks
Registered User
Posts: 636
Joined: 01 Feb 2006, 02:00
Location: Cape Town

Re: Monitoring db activity/usage in SQL Server 2005

Post by ArmatageShanks »

All I need to know is if the database is being used at all (for every database on a server).
I just need the most efficient way of determining this.
xchuckx has been flushed and respawned neo-nymbo
Post Reply