Sunday, September 30, 2007

Often I experienced the connection problem while connecting to SQL Server 2005 on Windows Vista with the message "login failed for user" even with an administrator account - sounds strange. 

Lets trace why this happens:

- In order to connect to SQL Server 2005 your account must be added to 'sysadmin' fixed server role.
- Windows Vista has a new feature called User Account Control or UAC in short which allows admins to manage privileges.
- By default accounts on Windows Vista are not part of 'sysadmin' fixed role.

Let's fix the problem

In order to add ordinary user to 'sysadmin' fixed server role - To add a normal user to the 'sysadmin' fixed role execute this system stored procedure

EXEC sp_grantlogin 'domain\user'
EXEC sp_addsrvrolemember 'domain\user', 'sysadmin'

After executing these stored procedure(s) user who has been granted login and added to 'sysadmin' fixed role no longer receive this error.

Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):