Not sure if the script is executing correctly. When I paste it into Host > SQL, it won't run unless I check "run as script", then it says it executed successfully.
If I try to run it directly in SQL manager, it won't run either, so I change the owners and object qualifiers to get it to run, which it does, but says "0 rows affected", so I don't think it's changing anything.
This is what I changed it to:
MERGE
INTO dbo.Portals P
USING
dbo.Roles R On P.PortalID = R.PortalID
WHEN
MATCHED
AND
R.RoleName Like 'Administrators'
AND
IsNull(P.AdministratorRoleId, -1) <> R.RoleID
THEN
UPDATE SET P.AdministratorRoleId = R.RoleId;
GO
MERGE
INTO dbo.Portals P
USING dbo.Roles R On P.PortalID = R.PortalID
WHEN
MATCHED
AND
R.RoleName Like 'Registered Users'
AND IsNull(P.RegisteredRoleId, -1) <> R.RoleID
THEN UPDATE SET P.RegisteredRoleId = R.RoleId;
GO