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
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.
Like @joshperry said, you can retrieve client address and server address with
SELECT client_net_address, local_net_address
FROM sys.dm_exec_connections
WHERE session_id = @@SPID
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With