SQL Server Profiler - how do I find which database is being connected?
Asked Answered
K

3

19

I've Googled this with no success. I'm using SQL Server Profiler for SQL Server 2008 R2, and I've ensured that for the 'Events Selection' of the trace:

  • I'm reporting all columns for Security Audit > Audit Login + Audit Logout
  • I'm reporting all columns for Sessions > ExistingConnection

I then start the trace after I've loaded an .aspx page, but just before I carry out an action that calls a certain SQL stored procedure.

I can then see at the start of my trace that under the 'EventClass' column I have 'ExistingConnection', however the 'TextData' for these events doesn't seem to identify the database I'm connecting to - it's telling me the main database settings (e.g. set ansi_padding on). I can also see that for certain events I can see the 'NTUserName', which gives me some clues. What I want to find though is which database am I connecting to. How can I determine this?

Kaczmarek answered 10/6, 2013 at 21:59 Comment(0)
C
32

When you create a new trace with SQL Server Profiler, a dialog is displayed titled "Trace Properties".

In the lower-right-hand corner you should see a checkbox labeled "Show all columns. Check it. Now scroll the table to the left and you should see a checkbox labeled "Database Name". Check that, and start the trace!

TraceProperties dialog

Converted answered 10/6, 2013 at 22:5 Comment(3)
Thanks! I thought 'Show all columns' would select all of the columns for display in the trace.Kaczmarek
@ChrisHalcrow - Glad to be of help!Converted
BTW "Show all columns" is in the lower right hand corner in SQL Server 2014.Preponderance
E
3

From Trace properties -> Events Selection tab, you can show the Database Column. By default it is not shown.

Exosmosis answered 10/6, 2013 at 22:3 Comment(0)
B
1

The Database name for each trace can be found by Events Selection -> (select) Show all columns(bottom right corner) -> (if you are tracing SPs then under Stored Procedure check database name column and check it.

enter image description here

Billingsley answered 3/6, 2022 at 6:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.