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
Related content
Σχόλια
https://aka.ms/ContentUserFeedback.
Σύντομα διαθέσιμα: Καθ' όλη τη διάρκεια του 2024 θα καταργήσουμε σταδιακά τα ζητήματα GitHub ως μηχανισμό ανάδρασης για το περιεχόμενο και θα το αντικαταστήσουμε με ένα νέο σύστημα ανάδρασης. Για περισσότερες πληροφορίες, ανατρέξτε στο θέμα:Υποβολή και προβολή σχολίων για