1

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?

0

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

http://sqlblog.com/blogs/greg_low/archive/2009/02/02/much-ado-about-logins-and-sids.aspx

http://msdn.microsoft.com/en-us/library/ms176060.aspx

  • Looks like I weighed in on that sqlblog thread. :) – Ben Thul May 26 '11 at 11:57
0

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

0

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

0

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

0

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.

  • 1
    This (very old) question already has an accepted answer. – BE77Y Jun 17 '15 at 11:00
  • 1
    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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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