valid_user

Returns 1 if the specified ID is a valid user or alias in at least one database.

Syntax

valid_user(server_user_id [, database_id])

Parameters

Examples

Usage

  • valid_user returns 1 if the specified server_user_id is a valid user or alias in the specified database_id.

  • If you do not specify a database_id, or if it is 0, valid_user determines if the user is a valid user or alias on at least one database.

See also:
  • Transact-SQL Users Guide

  • sp_adduser in Reference Manual: Procedures

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

The permission checks for valid_user differ based on your granular permissions settings.

Granular PermissionsDescription
Enabled

With granular permissions enabled, you must have manage any login or manage server permission to execute valid_user on a server_user_id other than your own.

Disabled

With granular permissions disabled, you must be a user with sa_role or sso_role to execute valid_user on a server_user_id other than your own.