| title | sp_grantlogin (Transact-SQL) | Microsoft Docs | ||
|---|---|---|---|
| ms.custom | |||
| ms.date | 03/14/2017 | ||
| ms.prod | sql | ||
| ms.prod_service | database-engine | ||
| ms.reviewer | |||
| ms.technology | system-objects | ||
| ms.topic | language-reference | ||
| f1_keywords |
|
||
| dev_langs |
|
||
| helpviewer_keywords |
|
||
| ms.assetid | 0c873d99-c3bf-4eb1-948b-a46cb235ccd4 | ||
| ms.author | vanto | ||
| author | VanMSFT |
[!INCLUDEtsql-appliesto-ss2008-xxxx-xxxx-xxx-md]
Creates a [!INCLUDEssNoVersion] login.
Important
[!INCLUDEssNoteDepFutureAvoid] Use CREATE LOGIN instead.
Transact-SQL Syntax Conventions
sp_grantlogin [@loginame=] 'login'
[ @loginame = ] 'login'
Is the name of a Windows user or group. The Windows user or group must be qualified with a Windows domain name in the form Domain\User; for example, London\Joeb. login is sysname, with no default.
0 (success) or 1 (failure)
sp_grantlogin calls CREATE LOGIN, which supports additional options. For information on creating SQL Server logins, see CREATE LOGIN (Transact-SQL)
sp_grantlogin cannot be executed within a user-defined transaction.
Requires ALTER ANY LOGIN permission on the server.
The following example uses CREATE LOGIN to create a [!INCLUDEssNoVersion] login for the Windows user Corporate\BobJ. This is the preferred method.
CREATE LOGIN [Corporate\BobJ] FROM WINDOWS;
GO Security Stored Procedures (Transact-SQL)
CREATE LOGIN (Transact-SQL)
System Stored Procedures (Transact-SQL)