Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have a database called 'foo' on the first sql server instance called 'SQL01' that is backed up nightly via a snapshot with Snap Manager for SQL Server and then flex cloned and restored to a second server instance called 'SQL02'. In the database foo there is a sql user called 'someuser' that has datareader and stored procedure privileges.

After the restore operation I cannot access the foo database on SQL02 with the someuser user. I can see that the permissions appear to be set correctly for the user, but can't access the database. The error is "The server principal "someuser" is not able to access the database "foo" under the current security context."

If I remove the user from the database and then add them again it works fine. Any ideas?

share|improve this question
up vote 0 down vote accepted

sp_change_users_login is old way of doing things and since you are using SQL Server 2005, try using ALTER USER syntax.

share|improve this answer
Looks like I weighed in on that sqlblog thread. :) – Ben Thul May 26 '11 at 11:57

Check out sp_change_users_login Do a sp_change_users_login 'report', if there are results, use sp_change_users_login 'autofis','someuser'

share|improve this answer

you will probably find you need to delete the user out of the database you have restored, then open the user under server security and set its permissions into that DB again

share|improve this answer

The server logins are stored in the master database and are not moved with the application DBs. You can create the login at the server level and then use sp_change_users_login 'auto_fix','loginname' as suggested by Sankar. To move a larger set of logins, check this link: How to transfer logins and passwords between instances of SQL Server

share|improve this answer

To avoid this issue add your user ( the user who is taking backup) as a user of the Backup database, and your user should have (login) access in the new instance.

share|improve this answer
This (very old) question already has an accepted answer. – BE77Y Jun 17 '15 at 11:00
Not only has an accepted answer as stated by @BE77Y but does not offer any added value to previous answers – alphamikevictor Jun 17 '15 at 12:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.