Was this page helpful?
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

HOST_ID (Transact-SQL)


Applies To: SQL Server 2014, SQL Server 2016 Preview

Returns the workstation identification number. The workstation identification number is the process ID (PID) of the application on the client computer that is connecting to SQL Server.

Applies to: SQL Server (SQL Server 2008 through current version).

Topic link icon Transact-SQL Syntax Conventions



When the parameter to a system function is optional, the current database, host computer, server user, or database user is assumed. Built-in functions must always be followed by parentheses.

System functions can be used in the select list, in the WHERE clause, and anywhere an expression is allowed.

The following example creates a table that uses HOST_ID() in a DEFAULT definition to record the terminal ID of computers that insert rows into a table recording orders.

   (OrderID     int       PRIMARY KEY,
    CustomerID  nchar(5)  REFERENCES Customers(CustomerID),
    TerminalID  char(8)   NOT NULL DEFAULT HOST_ID(),
    OrderDate   datetime  NOT NULL,
    ShipDate    datetime  NULL,
    ShipperID   int       NULL REFERENCES Shippers(ShipperID));
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft