Click here to Skip to main content
15,672,526 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In sql server when you get the ipconfig using the cmdshell it returns the ip address of the machine which the database engine is running on.
but I have one sql server engine and multiple users over the network with their own applications, all of their applications are using the sa login, so when they run my sp to get their ipconfig it returns the ip address of the main machine.
how can I take their own ip addresses.

Lets say it's going to give me a record in my log table like;

Date | Time | Login UserName | user ip address

and I don't know how to achieve it.

any help or advice would be helpful and I'm grateful for that,


What I have tried:

I'm reading the cmdshell right now but I still haven't found an answer for it.
Updated 3-Nov-16 5:34am
[no name] 5-Oct-16 6:25am    
SQL Server doesn't know or care what the IP address of the users are.
m.r.m.40 5-Oct-16 6:39am    
I don't know about what you said, but it is possible to take the ip of the user.
[no name] 5-Oct-16 6:47am

So you've got multiple people using the SA account in SQL Server in the normal use of applications? Are you looking to have your databases destroyed either by accident or malice?

That's is a MASSIVE security risk. NOONE should be using the SA account for anything except the initial setup of the SQL server.
Share this answer

This could be a long process but you can get ip address with user name

first run
select * from sys.dm_exec_connections order by session_id
from above you will get session id,client_net_address

Now you have check with session id in sp_who to identify who is the user.

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900