Allows an Adaptive Server user to be known in a database as another user.
sp_addalias loginame, name_in_db
is the master.dbo.syslogins name of the user who wants an alternate identity in the current database.
is the database user name to alias loginame to. The name must exist in both master.dbo.syslogins and in the sysusers table of the current database.
There is a user named “albert” in the database’s sysusers table and a login for a user named “victoria” in master.dbo.syslogins. This command allows “victoria” to use the current database by assuming the name “albert”:
sp_addalias victoria, albert
Executing sp_addalias maps one user to another in the current database. The mapping is shown in sysalternates, where the two users’ suids (system user IDs) are connected.
A user can be aliased to only one database user at a time.
A report on any users mapped to a specified user can be generated with sp_helpuser, giving the specified user’s name as an argument.
When a user tries to use a database, Adaptive Server checks sysusers to confirm that the user is listed there. If the user is not listed there, Adaptive Server then checks sysalternates. If the user’s suid is listed in sysalternates, mapped to a database user’s suid, Adaptive Server treats the first user as the second user while using the database.
If the user named in loginame is in the database’s sysusers table, Adaptive Server does not use the user’s alias identity, because it checks sysusers and finds the loginame before checking sysalternates, where the alias is listed.
Only the Database Owner or a System Administrator can execute sp_addalias.
System procedures sp_addlogin, sp_adduser, sp_dropalias, sp_helpuser