HOST_NAME

Transact-SQL Reference

Transact-SQL Reference

HOST_NAME

Returns the workstation name.

Syntax

HOST_NAME ( )

Return Types

nchar

Remarks

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.

Examples

This example creates a table that uses HOST_NAME() in a DEFAULT definition to record the workstation name of computers that insert rows into a table recording orders.

CREATE TABLE Orders
   (OrderID     INT        PRIMARY KEY,
    CustomerID  NCHAR(5)   REFERENCES Customers(CustomerID),
    Workstation NCHAR(30)  NOT NULL DEFAULT HOST_NAME(),
    OrderDate   DATETIME   NOT NULL,
    ShipDate    DATETIME   NULL,
    ShipperID   INT        NULL REFERENCES Shippers(ShipperID))

See Also

Expressions

System Functions