SUSER_ID#

Returns the server principal id of the specified login or server role.

Syntax#

SUSER_ID ( [ 'login' ] )

Arguments#

‘login’

Is the name of a login or of a server role. login is sysname and is optional. When login is not specified, the id of the login of the current session is returned. When the parameter contains NULL, SUSER_ID returns NULL. Name matching is case-insensitive. When login matches neither a login nor a server role, SUSER_ID returns NULL.

Logins and server roles share one pool of ids, so the value is the principal_id the same principal shows in sys.server_principals and can be joined to sys.server_role_members and sys.sql_logins directly.

Return types#

int

Examples#

SELECT SUSER_ID();
SELECT SUSER_ID('admin');
SELECT SUSER_ID('sysadmin');

See Also#