SID mismatch of logins between servers

SID mismatch of logins happens between two servers if it is Always On between two replicas. The main thing that we need to remember here is
SID mismatch happens only between SQL Server Authentication logins not between Windows
authentication logins.In this case there is a mismatch between primary and secondary replica SID’s.  So I am matching with Primary
replica and creating logins in secondary , even the logins appears under secondary replica end, we need to drop and recreated with new SID.
 
use AdventureWorks2012
GO
SELECT *FROM sys.sysusers
GO
--Get the
info from Primary replica 
SELECT *from AdventureWorks2012.sys.sysusers users INNER JOIN sys.sql_logins  logins
ON users.sid=logins.SID
WHERE logins.principal_id not in (257,390)
--Run the
below query in secondary replica.This SID is we can get it above join query
CREATE LOGIN
LoginNameHere WITH PASSWORD=N'uuHEN6O0a9aXwytQ7c9Awt1DAtsuqZStXqucIhpDyUw=',SID=0x1B12074761E71447881EF964F2702958

Comments

Popular posts from this blog

System.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out

Pre login Handshake or Connection Timeout Period

Transparent Data Encryption(TDE) with Master Key and Certificate in SQL Server