2

Does SQL Server have the equivalent of tailing the log in MySQL?

It's really simple way to debug web apps. However I can't find a way to do this in SQL Server.

When I use the profiler I am given many options when starting a new trace. I can get it to output the SQL that is executed from management studio but not my app (it's definitely pointed at the same instance).

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
handles
  • 7,639
  • 17
  • 63
  • 85

1 Answers1

6

SQL Server Profiler is the right tool for the job, normally I use these settings (out of lazyness because these are more-or-less the defaults) and it should show all queries run against the SQL instance that you are connected to

Screenshot of SQL Server profiler settings

If you don't see all the queries you are expecting then there are a couple of things to try:

  • Check the Column Filters - you might have a filter (e.g. on database) that you were not aware of
  • Check SQL:BatchCompleted and RPC:Completed are both selected - queries run will appear under one of these events depending on whether its a stored procedure or an ad-hoc query being run.

If you still don't see your query under here then I would double check that your application is running queries and that they are running against the correct database (SQL Profiler is normally the method I use to verify this if I'm in any doubt)

Justin
  • 84,773
  • 49
  • 224
  • 367
  • Brilliant, exactly what I was looking for. Thanks for the really quick response. – handles Oct 10 '17 at 11:49
  • SQL Server Profiler has been [deprecated](https://learn.microsoft.com/en-us/sql/tools/sql-server-profiler/sql-server-profiler?view=sql-server-ver16). Use [Extended Events](https://learn.microsoft.com/en-us/sql/relational-databases/extended-events/extended-events?view=sql-server-ver16) or [SSMS XEvent Profiler](https://learn.microsoft.com/en-us/sql/relational-databases/extended-events/use-the-ssms-xe-profiler?view=sql-server-ver16) instead – kkuilla Oct 14 '22 at 09:43