Home > SQL Server, T-SQL > Check access to the database using HAS_DBACCESS – SQL Server

Check access to the database using HAS_DBACCESS – SQL Server


HAS_DBACCESS():  This function is used to check whether the user has access to the given database or not. This function returns an integer value 1 or 0  or null.

If the return value is 1 then the user has access to the database. If the return value is null then the function argument is invalid. If the return value is 0 then the user does not have access to the database or the database is offline or suspect or single user mode or other user is using the database.

Function Syntax

HAS_DBACCESS ( ‘database_name’ )

Example

1. Check access to the current database.

pic1

 

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: