Skip to content

Latest commit

 

History

History
67 lines (48 loc) · 2.6 KB

File metadata and controls

67 lines (48 loc) · 2.6 KB
title xp_grantlogin (Transact-SQL)
description Grants a Windows group or user access to SQL Server.
author VanMSFT
ms.author vanto
ms.reviewer randolphwest
ms.date 06/23/2025
ms.service sql
ms.subservice system-objects
ms.topic reference
f1_keywords
xp_grantlogin
xp_grantlogin_TSQL
helpviewer_keywords
xp_grantlogin
dev_langs
TSQL

xp_grantlogin (Transact-SQL)

[!INCLUDE SQL Server]

Grants a Windows group or user access to [!INCLUDE ssNoVersion].

Important

[!INCLUDE ssNoteDepFutureAvoid] Use CREATE LOGIN instead.

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

xp_grantlogin { [ @loginame = ] 'login' } [ , [ @logintype = ] 'logintype' ]

Arguments

[ @loginame = ] 'login'

The name of the Windows user or group to be added. The Windows user or group must be qualified with a Windows domain name in the form <domain>\<user>. @loginame is sysname, with no default.

[ @logintype = ] 'logintype'

The security level of the login being granted access. @logintype is varchar(5), with a default of NULL. Only admin can be specified. If admin is specified, @loginame is granted access to [!INCLUDE ssNoVersion], and added as a member of the sysadmin fixed server role.

Return code values

0 (success) or 1 (failure).

Remarks

xp_grantlogin is a system stored procedure instead of an extended stored procedure. xp_grantlogin calls sp_grantlogin and sp_addsrvrolemember.

Permissions

Requires membership in the securityadmin fixed server role. Changing the @logintype requires membership in the sysadmin fixed server role.

Related content