Sql-server – Why is a Login losing a User mapping

sql serversql-server-2008

Is there any way to determine why is a Login is losing a User mapping?

I've created them with the following SQL …

CREATE LOGIN [qauser] WITH PASSWORD = 'xxxx', DEFAULT_DATABASE = [app_tst],  
                           CHECK_EXPIRATION=OFF, CHECK_POLICY = OFF

CREATE USER [qauser] FOR LOGIN [qauser] WITH DEFAULT_SCHEMA = [devdba]

and then successfully used the matching login on a linked server with synonyms to tables in the original.

Some time later, the synonyms fail and checking the LOGIN properties, the User Mapping have gone for the database / user. I have to re-run the CREATE LOGIN / USER script to get them to work … but using the main devdba login, the synonyms continues to work

What could be causing this loss ?

Best Answer

From the post here (user mapping disappearing):

"The only time I have seen something like this happen, was when the application DBAs where restoring test scenario DB backups over the existing databases, without telling us SQL Server SysAdmins what they were doing. This would of course wipe out all of our later user mappings to those databases. So, you might want to check for something like that... "

And in the same thread, a pointer to a script for knowing when the database was last restored.