StumbleUpon
Share on Facebook

Friday, April 27, 2007

Check database permission

Check Access to database

Check if user has access to the specified database

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

Begin
Declare @RetValue Int;
Set @RetValue = HAS_DBACCESS('AdventureWorks')
IF @RetValue = 1
Print 'User has Access';
Else
IF @RetValue = 0
Print 'User Does not have Access';
Else
Print 'Database name is not valid';
End

Check for Valid Database Name, DB Name Error, DB Name Validity, User Permissions for DB, User Access for DB, User Rights for DB, SQL Server Check Access to database

No comments:

Related Posts Plugin for WordPress, Blogger...