System varialble to get client pc computer name

  • Is there a way to get the computer name from pc that is accessing a sql db. I know how to get user is there something similar for computer name?

    thanks,

    vmon

  • Hi vmon,

    yes, have a look at sys.dm_exec_sessions and in there the host_name column.

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • Just to add, for your current session you can do:

    SELECT host_name

    FROM sys.dm_exec_sessions

    WHERE session_id = @@SPID

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • Great! Thanks a bundle.

    vmon

  • There is a system function to get it for the current connection:

    select host_name()

    Keep in mind that this value is completely configurable in your connection string. So, if the programmer (or the user if they can access the connection string for an application) sets the host name in the connection string to something else, that is what will be returned.

  • Note that those values are populated at will by the client application ( in the connection string )


    * Noel

Viewing 6 posts - 1 through 5 (of 5 total)

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