To add an alias for a user, use sp_addalias. The syntax is:
sp_addalias loginame, name_in_db
where:
loginame – is the name of the user who wants an alias in the current database. This user must have an account in Adaptive Server but cannot be a user in the current database.
name_in_db – is the name of the database user to whom the user specified by loginame is to be linked. The name_in_db must exist in both master..syslogins and in sysusers in the current database.
Executing sp_addalias maps the user name specified by loginame to the user name specified by name_in_db. It does this by adding a row to the system table sysalternates.
When a user tries to use a database, Adaptive Server checks for the user’s server user ID number (suid) in sysusers. If it is not found, Adaptive Server then checks sysalternates. If the user’s suid is found there, and it is mapped to a database user’s suid, the first user is treated as the second user while the first user is using the database.
For example, suppose that Mary owns a database. She wants to allow both Jane and Sarah to use the database as if they were its owner. Jane and Sarah have logins on Adaptive Server but are not authorized to use Mary’s database. Mary executes the following commands:
sp_addalias jane, dbo exec sp_addalias sarah, dbo
WARNING! Users who are aliased to the Database Owner have all the permissions and can perform all the actions that can be performed by the real Database Owner, with respect to the database in question. A Database Owner should carefully consider the implications of vesting another user with full access to a database.