views:

366

answers:

3

Hello,

i need to clearly see what IP address made what sql query to SQL server. I am trying to use SQL Profiler, but it seems there is no way i can somehow to differentiate the machine (browser) where the query came from. It only has the communication details between the web server and the sql server. Is there ANY way for me (any unknown log?) that will allow me to see the identification of the original machine where the query came from?

Thanks for any suggestion.

HF

A: 

If you do not write code in the application to pass the client address from the web server to the database you will have to look at the web logs - they will give the ip address of the client.

Mark
+2  A: 

As far as SQL Server is concerned the request will always come from your webserver. You need to capture and log the IP address in your web app.

RMcLeod
A: 

You can get the hostname of the current connection, or really any information from the sysprocesses table

SELECT hostname FROM sys.sysprocesses WHERE spid = @@SPID

This obviously won't work to get the ip address of web hosts if that's what you're looking for.

joshperry