Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to get local machine name using sql server. I tried querying the sys.sysprocesses,sys.dm_exec_connections and sys.dm_exec_sessions, but all the views only tracks host names of server. How to retrieve the client PC's computer name
Posted
Updated 6-Nov-13 17:34pm
v2

try this

SELECT SERVERPROPERTY('MachineName').

i hope it will work for you.
 
Share this answer
 
Comments
ArunRajendra 6-Nov-13 23:45pm    
Doesnot work its gives Server name.
SQL
SELECT s.hostname,s.[status],s.cmd,s.program_name,d.[text]
FROM sys.sysprocesses s
CROSS APPLY
sys.dm_exec_sql_text(s.sql_handle) d
--WHERE s.hostname ='Systemname'

you can even get what the client currently execute
 
Share this answer
 
try this
SELECT HOST_NAME()
it is working for me
 
Share this answer
 
Comments
Sugu.s 6-Nov-13 8:17am    
This way returns only host name not client machine name...

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