Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Recording all sql executed against a database

Author  Topic 

alanlambert
Starting Member

26 Posts

Posted - 2010-01-10 : 12:36:09
I have been asked to look at a CMS running behind several production websites that's using a sql 2005 database. For some reason every now and again the information for a website's home page is being lost.

The code for the CMS (ASP.NET) is pretty terrible with all data access being done from inline sql distributed all over the pages and no centralised data handling code. It is therefore very difficult trying to find exactly what is happening to cause this problem.

I was wondering if there is a way to automatically record every sql statement executed against a database so I can start to try to understand what's happening. Is there a way to do this or can you recommend a better approach?

I'm really tearing my hair out over this so am incredibly greatful for any help you can give.

Alan

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-01-10 : 12:46:44
You can do this by running a trace in SQL Profiler.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

alanlambert
Starting Member

26 Posts

Posted - 2010-01-11 : 02:39:21
Tara

Thanks very much for the advice. I've had a look at Profiler and, as you suggest, it gives me exactly what I need.

On other quick question though - what affect is logging every sql statement to a database table going to have on the performance of the main database?

Thanks again

Alan
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-01-11 : 13:26:49
Check out my blog article on how to run Profiler to avoid causing performance issues: http://weblogs.sqlteam.com/tarad/archive/2008/08/06/SQL-Profiler-best-practices.aspx

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

alanlambert
Starting Member

26 Posts

Posted - 2010-01-12 : 03:18:07
Tara

Thank you again for your help

Alan
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-01-12 : 04:25:34
If you struggle to Filter your Performance Monitor Profiler data mountain :) enough to make it easy to find the row you are looking for you could consider putting a trigger on the CMS table and insert an entry into a LOG table (with Date/Time/UserID) when the row in the CMS table relating to your Home Pages changes (that in turn could alert you I suppose). That would give you Date/Time to look for in your Performance Monitor Profiler data.

Alternatively ServersAlive (freebie for up to 10 monitor locations I think) could alert you the moment that some text disappears from the Home Page - that would give you a timestamp too.

Edit: Sorry, dyslexic-brain-fade
Go to Top of Page
   

- Advertisement -