Scripting SQL Logins, Windows Logins, group membership

SQL
I'm working with AlwaysOn Availability Groups in SQ'L 2014. One of the many interesting gotchas I have with AlwaysOn is that SQL Logins on each AG node must be created with identical SIDs, otherwise after failover the database users for those SQL Logins will be orphaned. I discovered Bill Graziano's post back from 2010 where he scripts out the SQL Logins (including SID and hashed password), plus the Windows logins and server role membership for SQL 2008 server. I have adapted it for SQL 2014 SP2. Note the script was originally designed to script out the logins only if they do not exist already. I removed the 'IF NOT EXISTS' lines so it will script out all the SQL Logins and Windows Logins regardless of whether they exist. USE [master] GO /* Object: UserDefinedFunction…
Read More