Home > T-SQL > Get Host ID and Name – SQL Function

Get Host ID and Name – SQL Function

HOST_ID() function returns a ten character workstation identification number. This number is an application process ID running in the client computer.

HOST_NAME() function returns the client computer name. The return value of this function is nvarchar(128).


select HOST_ID()

Output: <Process ID>

In my computer, it shows 3216 and to double-check this number I open the task manager and look at my SSMS process ID as shown below.


select HOST_NAME()

Output: <Client Computer name>

You can execute these queries in your management studio and see the output. We can use Host ID and Name in your application as an identification value. such as, storing client machine name as a column value to check who has inserted a row into the table.

But, please note that the HOST_NAME can provide inaccurate data. So, avoid using this as a security feature in your application.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: