Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Collapse the table of content
Expand the table of content
Expand Minimize

sp_grantlogin (Transact-SQL)

Creates a SQL Server login.

This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use CREATE LOGIN instead.

Topic link icon 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 SQL Server login for the Windows user Corporate\BobJ. This is the preferred method.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft