views:

1118

answers:

3

In a project of mine the SQL statements that are executed against a ms SQL server are failing for some unknown reason. Some of the code is already used in production so debugging it is not an easy task. Therefore I need a way to see in the database itself what SQL statements are used, as the statements are generated at runtime by the project and could be flawed when certain conditions are met.

I therefore considered the possibility to monitor the incoming statements and check myself if I see any flaws.

The database is running on a ms SQL server 2005, and I use SQL server management studio express as primary tool to manipulate the database. So my question is, what is the best way to do this?

A: 

Best way is to fire up profiler, start a trace, save the trace and then rerun the statements

SQLMenace
Everyone may not have profiler like it was with Sven
Ismail
+10  A: 

Seeing how you use the Management Studio Express, I will assume you don't have access to the MSSQL 2005 client tools. If you do, install those, because it includes the SQL profiler which does exactly what you want (and more!). For more info about that one, see msdn.

I found this a while ago, because I was thinking about the exact same thing. I have access to the client tools myself, so I don't really need to yet, but that access is not unlimited (it's through my current job). If you try it out, let me know if it works ;-)

Erik van Brakel
sqlprofiler is exactly what I needed, thank you!. It took me a while to figure out what events I needed to log (RPCCompleted) for my purposes, but seeing the amount of events you can log, I think it will also suit your needs as well.
Sven
+2  A: 

This is very nice.

http://sqlprofiler.googlepages.com/

Ismail
I had no idea this application existed - thanks for the link!
rwmnau