Jaa


SUSER_ID (Transact-SQL)

Returns the login identification number of the user.

Note

SUSER_ID always returned NULL when it is used in Microsoft SQL Server 2000. In SQL Server 2005, SUSER_ID returns the value listed as principal_id in the sys.server_principals catalog view.

Topic link iconTransact-SQL Syntax Conventions

Syntax

SUSER_ID ( [ 'login' ] ) 

Arguments

  • 'login'
    Is the login name of the user. login is nchar. If login is specified as char, login is implicitly converted to nchar. login can be any SQL Server login or Microsoft Windows user or group that has permission to connect to an instance of SQL Server. If login is not specified, the login identification number for the current user is returned.

Return Types

int

Remarks

SUSER_ID returns an identification number only for logins that have been explicitly provisioned inside SQL Server. This ID is used within SQL Server to track ownership and permissions. This ID is not equivalent to the SID of the login that is returned by SUSER_SID. If login is a SQL Server login, the SID maps to a GUID. If login is a Windows login or Windows group, the SID maps to a Windows security identifier.

SUSER_SID returns a SUID only for a login that has an entry in the syslogins system table.

System functions can be used in the select list, in the WHERE clause, and anywhere an expression is allowed, and must always be followed by parentheses, even if no parameter is specified.

In SQL Server version 7.0, the security identification number (SID) replaced the server user identification number (SUID).

Examples

The following example returns the login identification number for the sa login.

SELECT SUSER_ID('sa')

See Also

Reference

sys.server_principals (Transact-SQL)
SUSER_SID (Transact-SQL)
System Functions (Transact-SQL)

Help and Information

Getting SQL Server 2005 Assistance