user_id

Description

Returns the ID number of the specified user or of the current user in the database.

Syntax

user_id([user_name])

Parameters

user_name

is the name of the user.

Examples

Example 1

select user_id()
------ 
    1 

Example 2

select user_id("margaret")
------
    4 

Usage

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

You must System Administrator or System Security Officer to use this function on a user_name other than your own.

See also

Commands setuser

Documentation Transact-SQL Users Guide

Functions suser_id, user_name