Skip to content

Latest commit

 

History

History
70 lines (51 loc) · 2.73 KB

File metadata and controls

70 lines (51 loc) · 2.73 KB
title sp_validatelogins (Transact-SQL)
description Reports information about Windows users and groups that are mapped to SQL Server principals but no longer exist in the Windows environment.
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
sp_validatelogins
sp_validatelogins_TSQL
helpviewer_keywords
sp_validatelogins
dev_langs
TSQL

sp_validatelogins (Transact-SQL)

[!INCLUDE SQL Server]

Reports information about Windows users and groups that are mapped to [!INCLUDE ssNoVersion] principals but no longer exist in the Windows environment.

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

Syntax

sp_validatelogins
[ ; ]

Return code values

0 (success) or 1 (failure).

Result set

Column name Data type Description
SID varbinary(85) Windows security identifier (SID) of the Windows user or group.
NT Login sysname Name of the Windows user or group.

Remarks

If the orphaned server-level principal owns a database user, the database user must be removed before the orphaned server principal can be removed. To remove a database user, use DROP USER. If the server-level principal owns securables in the database, ownership of the securables must be transferred or they must be dropped. To transfer ownership of database securables, use ALTER AUTHORIZATION.

To remove mappings to Windows users and groups that no longer exist, use DROP LOGIN.

Permissions

Requires membership in the sysadmin or securityadmin fixed server role.

Examples

The following example displays the Windows users and groups that no longer exist but are still granted access to an instance of [!INCLUDE ssNoVersion].

EXECUTE sp_validatelogins;
GO

Related content