<p>In a project of mine the SQL statements that are executed against a 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. </p>

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

<p>The database is running on a 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?</p>

[{'answer_id': 47379, 'author': 'SQLMenace', 'author_id': 740, 'author_profile': 'https://Stackoverflow.com/users/740', 'pm_score': 2, 'selected': False, 'text': '<p>Best way is to fire up profiler, start a trace, save the trace and then rerun the statements</p>\n'}, {'answer_id': 47380, 'author': 'Erik van Brakel', 'author_id': 909, 'author_profile': 'https://Stackoverflow.com/users/909', 'pm_score': 6, 'selected': True, 'text': '<p>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 <a href="http://msdn.microsoft.com/en-us/library/ms181091.aspx" rel="noreferrer">msdn</a>.</p>\n\n<p>I found <a href="http://sqlprofiler.googlepages.com/" rel="noreferrer">this</a> 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 ;-)</p>\n'}]
['https://Stackoverflow.com/questions/47376', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/46/']