Returns the ID number of the specified user or of the current user in the database.
is the name of the user.
user_id, a system function, returns the user’s ID number. For general information about system functions, see “System functions”.
user_id reports the number from sysusers in the current database. If no user_name is supplied, user_id returns the ID of the current user. To find the server user ID, which is the same number in every database on Adaptive Server, use suser_id.
Inside a database, the “guest” user ID is always 2.
Inside a database, the user_id of the Database Owner is always 1. If you have the sa_role active, you are automatically the Database Owner in any database you are using. To return to your actual user ID, use set sa_role off before executing user_id. If you are not a valid user in the database, Adaptive Server returns an error when you use set sa_role off.
SQL92 – Compliance level: Transact-SQL extension.
You must System Administrator or System Security Officer to use this function on a user_name other than your own.
Functions suser_id, user_name