locked
can i get the client computer name ? RRS feed

  • Question

  • hi
     can i get the client computer name ? from sql server

    i  have a web application from sql server 2005

    can i get the client computer name (not the server)

    TNX
    Wednesday, August 5, 2009 12:47 PM

Answers

  • I missed this is a Web application... Agree with Ewan, in that case it is up to the Web application to provide the client info. In .NET you can use System.Net.Dns.GetHostEntry to get it:
    http://msdn.microsoft.com/en-us/library/ms143997(VS.85).aspx

    The remote IP address is available as server variable 'remote_addr'.
    Plamen Ratchev
    • Marked as answer by Zongqing Li Wednesday, August 12, 2009 6:22 AM
    Wednesday, August 5, 2009 1:30 PM
  • Hi gpspocket

    SQL Server cannot tell you the client. The web application needs to do it. Plamen's link shows how the web application may be changed to supply the data to SQL.

    Ewan

    If you have found this post helpful, please click the 'Vote as Helpful' link (the green triangle and number on the top-left).

    If this post answers your question, click the 'Mark As Answered' link below. It helps others who experience the same issue in future to find the solution.
    • Marked as answer by Zongqing Li Wednesday, August 12, 2009 6:22 AM
    Wednesday, August 5, 2009 2:19 PM

All replies

  • Try the HOST_NAME function:
    http://technet.microsoft.com/en-us/library/ms178598.aspx
    Plamen Ratchev
    • Proposed as answer by richbrownesq Wednesday, August 5, 2009 1:03 PM
    • Unproposed as answer by richbrownesq Wednesday, August 5, 2009 1:10 PM
    Wednesday, August 5, 2009 12:55 PM
  • Hi gpspocket

    If the connection to SQL comes directly from the web server and not a client, then the only way of finding out the client name is for the web application to provide it to you. SQL Server cannot 'see beyond' the web server.

    HTH

    Ewan

    If you have found this post helpful, please click the 'Vote as Helpful' link (the green triangle and number on the top-left).

    If this post answers your question, click the 'Mark As Answered' link below. It helps others who experience the same issue in future to find the solution.
    • Proposed as answer by Ewan Friday, August 7, 2009 9:08 AM
    Wednesday, August 5, 2009 1:04 PM
  • I missed this is a Web application... Agree with Ewan, in that case it is up to the Web application to provide the client info. In .NET you can use System.Net.Dns.GetHostEntry to get it:
    http://msdn.microsoft.com/en-us/library/ms143997(VS.85).aspx

    The remote IP address is available as server variable 'remote_addr'.
    Plamen Ratchev
    • Marked as answer by Zongqing Li Wednesday, August 12, 2009 6:22 AM
    Wednesday, August 5, 2009 1:30 PM
  • how can i run it inside sql server
    how to run C# ?
    can i execute it from stored procedure

    TNX
    Wednesday, August 5, 2009 1:53 PM
  • Hi gpspocket

    SQL Server cannot tell you the client. The web application needs to do it. Plamen's link shows how the web application may be changed to supply the data to SQL.

    Ewan

    If you have found this post helpful, please click the 'Vote as Helpful' link (the green triangle and number on the top-left).

    If this post answers your question, click the 'Mark As Answered' link below. It helps others who experience the same issue in future to find the solution.
    • Marked as answer by Zongqing Li Wednesday, August 12, 2009 6:22 AM
    Wednesday, August 5, 2009 2:19 PM