Udostępnij za pośrednictwem


HAS_DBACCESS (Transact-SQL)

Returns information about whether the user has access to the specified database.

Topic link iconTransact-SQL Syntax Conventions

Syntax

HAS_DBACCESS ( 'database_name' ) 

Arguments

  • 'database_name'
    Is the name of the database for which the user wants access information. database_name is sysname.

Return Types

int

Remarks

HAS_DBACCESS returns 1 if the user has access to the database, 0 if the user has no access to the database, and NULL if the database name is not valid.

Permissions

Requires membership in the public role.

Examples

The following example tests whether current user has access to the AdventureWorks database.

SELECT HAS_DBACCESS('AdventureWorks');
GO

See Also

Reference

IS_MEMBER (Transact-SQL)
IS_SRVROLEMEMBER (Transact-SQL)

Help and Information

Getting SQL Server 2005 Assistance