For SQL Server 6.5 information, see sp_addlogin in What's New for SQL Server 6.5.
Creates a new SQL Server user by adding an entry to master.dbo.syslogins.
sp_addlogin login_id [, passwd [, defdb [, deflanguage]]]
where
After sp_addlogin is executed, the user can log in to SQL Server.
When you are using integrated security, the presence or absence of a login ID determines if a user is uniquely known within SQL Server or is instead mapped to a default account, if one exists. If no default account and no login ID exists for a specific user, that user cannot log in.
The user can change his or her own password at any time by using the sp_password system stored procedure. The system administrator can change any user's password by using sp_password with NULL as the old password.
If the name of a default database is supplied (defdb), the user is connected to the specified database without the USE statement and without passing through master. However, the user cannot use the default database until given access to that database by its database owner (by using the sp_adduser or sp_addalias system stored procedure).
The user can change his or her own default database at any time by using the sp_defaultdb system stored procedure. The system administrator can change any user's default database by using sp_defaultdb.
The user can change his or her own default language at any by using the sp_defaultlanguage system stored procedure. The system administrator can change any user's default language by using sp_defaultlanguage.
This example creates a SQL Server login for the login ID Victoria. Since the passwd and defdb parameters are not included, Victoria's password is NULL and her default database is master.
sp_addlogin Victoria
This example creates a SQL Server login identification number for the user Albert. His password is food and his default database is corporate.
sp_addlogin Albert, food, corporate
This example creates a SQL Server login for Claire. Her password is caniche, her default database is public_db, and her default language is French.
sp_addlogin Claire, caniche, public_db, french
Only the system administrator can use this stored procedure.
master.dbo.sysdatabases, master.dbo.syslogins, master.dbo.syslanguages
sp_addalias | sp_helpuser |
sp_adduser | sp_password |
sp_defaultdb | xp_grantlogin |
sp_defaultlanguage | xp_logininfo |
sp_droplogin | xp_revokelogin |