--- YOU MUST EXECUTE THE FOLLOWING SCRIPT IN SQLCMD MODE.
:CONNECT SQL2K12-SVR1
ALTER AVAILABILITY GROUP [SQL2K12-AG1] FAILOVER;
GO


:CONNECT SQL2K12-SVR1
EXEC sys.sp_configure N'contained database authentication', N'1'
GO
RECONFIGURE WITH OVERRIDE
GO
:CONNECT SQL2K12-SVR2
EXEC sys.sp_configure N'contained database authentication', N'1'
GO
RECONFIGURE WITH OVERRIDE
GO
:CONNECT SQL2K12-SVR3
EXEC sys.sp_configure N'contained database authentication', N'1'
GO
RECONFIGURE WITH OVERRIDE
GO
:CONNECT SQL2K12-SVR4
EXEC sys.sp_configure N'contained database authentication', N'1'
GO
RECONFIGURE WITH OVERRIDE
GO
:CONNECT SQL2K12-SVR5
EXEC sys.sp_configure N'contained database authentication', N'1'
GO
RECONFIGURE WITH OVERRIDE
GO

-- Make Sure there are no connections the DB's when doing this!

:CONNECT SQL2K12-SVR1
USE [master]
GO
ALTER DATABASE [ERPDatabase] SET CONTAINMENT = PARTIAL WITH NO_WAIT
ALTER DATABASE [ConfigDB] SET CONTAINMENT = PARTIAL WITH NO_WAIT
GO
USE [ERPDatabase]
GO
EXECUTE sp_migrate_user_to_contained 
        @username = N'ERPLogin',
        @rename = N'keep_name',
        @disablelogin = N'disable_login';
GO
USE [ConfigDB]
GO
EXECUTE sp_migrate_user_to_contained 
        @username = N'ERPLogin',
        @rename = N'keep_name',
        @disablelogin = N'disable_login';
GO