Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).
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).
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.
CREATE TABLE 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)); GO