Have you encountered the error 'CREATE DATABASE Permission denied in database 'master'' even though you are logged into Windows Vista with administrator privileges.
Reason for the error : Windows Vista users that are members of the Windows Administrators group are not automatically granted permission to connect to SQL Server, and they are not automatically granted administrative privileges.
Resolution: Grant rights to the administrator. Follow these steps:
Step 1: Go to Start > All Programs > Microsoft SQL Server 2005 > Configuration Tools > SQL Server Surface Area Configuration.
Step 2: Click on 'Add New Administrator'.
Step 3: In the 'SQL Server User Provisioning on Vista' dialog box, look out for the 'Member of the SqlServer SysAdmin role ' in the 'Available Privileges' box. Transfer it to the 'Privileges that will be granted to' box. Click Ok.
Note: You will be able to see 'Add New Administrator' in the Configuration tool only if you have logged in as an administrator
Thursday, April 17, 2008
Check if a user has access to a database in Sql Server 2005
Method 1:HAS_DBACCESS returns information about whether the user has access to the specified database (BOL).
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]
Method 2:Other best alternative of the above command is you can use sp_helplogins without paramter for checking the existing user permissions and the database list
ex
1. sp_helplogins
2. sp_helplogins 'LoginName'
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]
Method 2:Other best alternative of the above command is you can use sp_helplogins without paramter for checking the existing user permissions and the database list
ex
1. sp_helplogins
2. sp_helplogins 'LoginName'
Subscribe to:
Posts
(
Atom
)