1 Version 4.0 -- 1/15/89 sp_addalias
______________________________________________________________________
NAME: sp_addalias
FUNCTION:
Maps one user to another in a database.
SYNTAX:
sp_addalias loginame, name_in_db
EXAMPLES:
sp_addalias victoria, albert
There is a user named albert in the database's sysusers table and
sp_addalias Version 4.0 -- 1/15/89 2
______________________________________________________________________
a login for a user named victoria in master.dbo.syslogins. This
command allows victoria to use the current database, and to be
known as albert when doing so.
PARAMETERS:
loginame - is the master.dbo.syslogins name of the user who
wants an alternate identity in the current database. An
alias allows a SQL Server user to be known in a database as
another user.
If the user with loginame exists in the database's sysusers
table, SQL Server won't find the user's alias identity, since
it checks sysusers before checking sysalternates.
name_in_db - is the name of the database user to whom the first
user wishes to be linked. The name must exist in both
master.dbo.syslogins and in the sysusers table of the current
database.
3 Version 4.0 -- 1/15/89 sp_addalias
______________________________________________________________________
COMMENTS:
o Executing sp_addalias maps one user (loginame) to another
(name_in_db) in the current database. The mapping is shown in
sysalternates, where the two users' suids are connected.
o A report on any users mapped to a specified user can be gen-
erated with sp_helpuser, giving the specified user's name as an
argument.
o When a user tries to use a database, SQL Server checks sysusers
to see if the user is listed there. If he or she is not there,
it then checks sysalternates. If an entry (the user's suid) is
found there, mapped to a database user's suid (altsuid in
sysalternates table), the first user is treated as the second
user while using the database.
o There are three ways that you can be authorized to use a
sp_addalias Version 4.0 -- 1/15/89 4
______________________________________________________________________
database (assuming you are listed in master.dbo.syslogins).
First, you can be listed in the sysusers table of that data-
base. (New database users are added by the Database Owner with
the sp_adduser system procedure.)
Second, you can have an alias in the database, which has been
added by the Database Owner using the sp_addalias procedure.
Third, you can use the database as guest if there is a guest
entry in the database's sysusers table.
MESSAGES:
The procedure was successful. Now the user with loginame can use
the current database. When doing so, he or she will be known
as name_in_db.
There is no entry in master.dbo.syslogins for loginame. Everyone
using SQL Server, whether aliased or not, must have a login.
5 Version 4.0 -- 1/15/89 sp_addalias
______________________________________________________________________
Since name_in_db is not a user in the database, loginame can't be
aliased to it.
The loginame is already aliased to a user in the current data-
base. A loginame may be aliased to only one database user at
a time. To change an alias, first drop the current alias
using sp_dropalias. Then add the new alias.
PERMISSIONS:
Execute permission to Database Owner.
TABLES USED:
sysalternates, sysusers, master.dbo.syslogins
SEE ALSO:
sp_addlogin, sp_adduser, sp_dropalias, sp_helpuser, USE