Geeks With Blogs
Nouman Zakir while (true) { Post.NewArticle(); }

HAS_DBACCESS returns information about whether the user has access to the specified database.


Example:
SELECT HAS_DBACCESS('Northwind');
returns
1 if the user has access to the database
0 if the user does not have access to the database
NULL if the database does not exist


Find all databases that the current user has access to
SELECT [Name] as DatabaseName
FROM master.dbo.sysdatabases
WHERE
ISNULL(HAS_DBACCESS ([Name]),0)=1
ORDER BY [Name]

Posted on Saturday, February 28, 2009 5:32 AM | Back to top


Comments on this post: Check access to databse in SQL Server

# re: Check access to databse in SQL Server
Requesting Gravatar...
Thats a gr8 stuff..thx a lot for the useful article..
Left by kapil vaichalkar on Jan 31, 2011 7:01 PM

Your comment:
 (will show your gravatar)
 


Copyright © Nouman Zakir | Powered by: GeeksWithBlogs.net | Join free