views:

96

answers:

2

We have a big system with several hundred concurrent users so sql profiler gives a bit too much information without appropriate filters. I'd like to see what SQL commands are run under my account and my account only. With account I mean the username I use to log in to the system. These user names are stored in a regular database table and thus can't as such be entered to any filter in sql profiler, I guess? But every user that logs in might have some unique id anyway even thou we all use the same SQL login/user?

So, the question is mostly how to get that unique value and which filter to use? Or is there any way to see this and only this in sql profiler?

A: 

Each appilcation, which connects to the SQL Server, has a unique host id (the value returned by the HOST_ID() function), and you can filter on it. Of course, first you have to connect to the database from your application, in order to get your host id.

The host id can also be found in the hostprocess column of the sysprocesses system table. And in Profiler it is called ClientProcessId.

treaschf
+3  A: 

You should be able to get the hostname of the machine connecting to SQL server. In the Trace Properties/Event Section tab, tick the Show all Columns option then in Column Filters you can specify HostName.

If you want to know the hostname of a machine you are using then at the command prompt type hostname

pjp
Thanks! Tried this one first and it works beautifully.
Micke