Export (0) Print
Expand All
Expand Minimize
0 out of 1 rated this helpful - Rate this topic

HAS_DBACCESS (Transact-SQL)

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

Topic link icon Transact-SQL Syntax Conventions


HAS_DBACCESS ( 'database_name' ) 
' database_name '

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

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.

Requires membership in the public role.

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

SELECT HAS_DBACCESS('AdventureWorks');
GO
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.