USER_ID

Transact-SQL Reference

Transact-SQL Reference

USER_ID

Returns a user's database identification number.

Syntax

USER_ID ( [ 'user' ] )

Arguments

'user'

Is the username to be used. user is nchar. If a char value is specified, it is implicitly converted to nchar.

Return Types

smallint

Remarks

When user is omitted, the current user is assumed. Parentheses are required.

USER_ID can be used in the select list, in the WHERE clause, and anywhere an expression is allowed. For more information, see Expressions.

Examples

This example returns the identification number for user Harold.

SELECT USER_ID('Harold')

See Also

Security Functions