Looking for a JavaEE Architect or Potential Tech Co-Founder?
Please don't hesitate to contact me.

Cannot open database "database" requested by the login. The login failed. Login failed for user 'user'

Often you will encounter this error if you are restoring a database from one machine into another.

What causes the error:
On a full backup of the database, it includes all the objects within it like tables, views, procedures, etc and also the users.

So when we restore the database on another machine, and the user is not on that machine. Or if it is there, the mapping would be deleted.

What to do:

1.) Execute this:
exec sp_revokedbaccess 'username'
http://msdn.microsoft.com/en-us/library/ms188909.aspx
This would delete the carried user in the database

2.) Now open your MSSQL Server Managerment Studio

3.) Click Security->Logins

4.) Right click the "user" click Properties, and in the "User Mapping" tab click the appropriate rights that we want the user to have for the database chosen
Cannot open database "database" requested by the login. The login failed. Login failed for user 'user' Cannot open database "database" requested by the login. The login failed. Login failed for user 'user' Reviewed by Edward Legaspi on Thursday, October 14, 2010 Rating: 5

1 comment:

Anonymous said...

Thanks a lot. I and another colleague of mine spent a lot of time figuring out this issue but finally resolved it with your solution.

Powered by Blogger.