Nouman Zakir

while (true) { Post.NewArticle(); }
posts - 13, comments - 12, trackbacks - 0

My Links

News

Archives

Post Categories

Personal Website

Check access to databse in SQL Server

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]

Print | posted on Saturday, February 28, 2009 5:32 AM |

Feedback

No comments posted yet.
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 

Powered by: