Inspecting the SQL commands received by a server

  • Hi there,

    I'm trying to squash a strange ASP.NET application bug. If I could take a peek of the SQL commands (select, insert, etc.) received by the server from the SQLDataSource controls on my pages, that would be of great help.

    Any ideas on how can I do this? Is there a log or system table where I can see all the SQL commands (in plain text) received by a certain database on the server? I'm working with SQL Server 2005 and ASP.NET 4.0 (Beta 2).

    Thanks in advance for any ideas,

    -Benton

  • A server-side trace or Profiler is the best way to do that.

    What you want is the Batch Complete event, and you want the Text column.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Thank you, GSquared. I found a working example here: http://www.dbazine.com/sql/sql-articles/larsen6

    Regards,

    -Benton

  • Make sure you are getting both the T-SQL commands and the stored procedures being run against the server.

    Joie Andrew
    "Since 1982"

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply