MSSQL镜像故障转移:用户login失败

MSSQL数据库镜像失败时,我们的脚本将不会login,失败:

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

我可以解决这个问题的方法是运行:

 USE YourDB GO EXEC sp_change_users_login 'Auto_Fix', 'MyUsername', NULL, 'MyPassword' GO 

我如何sorting这样login只是自动工作?

发现我们需要用相同的SID重新创build镜像服务器上的login。

http://social.msdn.microsoft.com/Forums/en/sqldatabaseengine/thread/5b2b7404-69d3-44cf-b522-fae1e6712a8b

另一种解决scheme可能是依靠域帐户(其中SID由域pipe理),而不是SQL Server帐户,其中默认SID是特定于实例的。

罗伯特·戴维斯是唯一的DBM书的作者,是一个MCM。 尝试下面,如果有帮助。

http://www.sqlsoldier.com/wp/sqlserver/databasemirroringautomation