sp_grantlogin Home
This page is specific to: Version:SQL Server 2000
Transact-SQL Reference (SQL Server 2000)
sp_grantlogin

Allows a Microsoft® Windows NT® user or group account to connect to Microsoft SQL Server™ using Windows Authentication.

Syntax

sp_grantlogin [@loginame =] 'login'

Arguments

[@loginame =] 'login'

Is the name of the Windows NT user or group to be added. The Windows NT user or group must be qualified with a Windows NT domain name in the form Domain\User, for example London\Joeb. login is sysname, with no default.

Return Code Values

0 (success) or 1 (failure)

Remarks

Use sp_grantlogin to reverse the effects of a previous sp_denylogin that has been executed for a Windows NT user.

Use sp_addlogin to allow a SQL Server login to connect to SQL Server.

Although a login can connect to SQL Server after sp_grantlogin has been executed, access to user databases is denied until a user account for the login is created in each database that the login must access. Use sp_grantdbaccess to create a user account in each user database.

sp_grantlogin cannot be executed within a user-defined transaction.

Permissions

Only members of the sysadmin or securityadmin fixed server roles can execute sp_grantlogin.

Examples

This example allows the Windows NT user Corporate\BobJ to connect to SQL Server.

EXEC sp_grantlogin 'Corporate\BobJ'

Or

EXEC sp_grantlogin [Corporate\BobJ]

See Also

sp_addlogin

sp_revokelogin

sp_denylogin

System Stored Procedures

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View