Lookign for the Name of requestor's machine

  • Hi,

    I am building a driver table for an automation project. I can use SUSER_SNAME() to grab the username when an entry is made into this driver table.

    How do I get the name of machine when the entry is made (in SQL2005)?

    Example:

    User name: JDoe

    Machine name: Client_123

    Need to produce "JDOe" --> SELECT SUSER_SNAME()

    Need to produce "Client_123" --> ???

    Thanks!

  • I am not sure that there is an equivalent of SUSER_SNAME()

    but you could possibly get the info from sysprocesses.

    select hostname from sys.sysprocesses

    where sid = SUSER_SID()

    this is only a suggestion as I havent used this before and

    there may be security issues with accessing sysprocesses

  • Interesting thought but returns several records. The hostname parameter did put me in the right direction for a new Google search, which resulted in the following:

    SELECT HOST_NAME() AS HOST_NAME

    Reference:

    http://blog.namwarrizvi.com/?p=127

    Good Luck

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply