संपादित करें

इसके माध्यम से साझा किया गया


sp_grantlogin (Transact-SQL)

Applies to: SQL Server

Creates a SQL Server login.

Important

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

Transact-SQL syntax conventions

Syntax

sp_grantlogin [ @loginame = ] N'loginame'
[ ; ]

Arguments

[ @loginame = ] N'loginame'

The name of a Windows user or group. @loginame is sysname, with no default. The Windows user or group must be qualified with a Windows domain name in the form <domain>\<user>; for example, London\Joeb.

Return code values

0 (success) or 1 (failure).

Remarks

sp_grantlogin calls CREATE LOGIN, which supports extra options. For information on creating SQL Server logins, see CREATE LOGIN

sp_grantlogin can't be executed within a user-defined transaction.

Permissions

Requires membership in the securityadmin fixed server role.

Examples

The following example uses CREATE LOGIN to create a SQL Server login for the Windows user Corporate\BobJ, which is the preferred method.

CREATE LOGIN [Corporate\BobJ] FROM WINDOWS;
GO