Finding user names and IDs

To find a user’s server user ID or login name, use suser_id and suser_name.

Table 10-10: System functions suser_id and suser_name

To find

Use

With the argument

Server user ID

suser_id

(["server_user_name"])

Server user name (login name)

suser_name

([server_user_ID])

The arguments for these system functions are optional. If you do not provide one, Adaptive Server displays information about the current user.

This example shows how to find the server user ID for the user “sandy:”

select suser_id("sandy")
------
     3

This example shows how a System Administrator whose login name is “mary” issues the commands without arguments:

select suser_name(), suser_id()
------------------------------ ------
mary                                4

To find a user’s ID number or name inside a database, use user_id and user_name.

Table 10-11: System functions user_id and user_name

To find

Use

With the argument

User ID

user_id

([“db_user_name”])

User name

user_name

([db_user_ID])

The arguments for these functions are optional. If you do not provide one, Adaptive Server displays information about the current user. For example:

select user_name(10) 
select user_name( ) 
select user_id("joe")