Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
langsql
titleInserts ResourceKeys for Users that have Domain details populated, but no corresponding resource Key exists
INSERT INTO ResourceKey(ResourceGuid, KeyName, KeyValue)
selectSELECT GWU._ResourceGuid, 'name.domain', upperUPPER(GWU.UserId) + '.' + upperUPPER(GWU.Domain))
fromFROM Inv_Global_Windows_Users GWU
WHERE NOT EXISTS (
	(selectSELECT 1 fromFROM ResourceKey RK 
where	WHERE RK.KeyName = 'name.domain' andAND RK.KeyValue = (upperUPPER(GWU.UserId) + '.' + upperUPPER(GWU.Domain))
) 	AND UserId IS NOT NULL
Code Block
langsql
titleUpdates ResourceKeys for Users that have Resource Key that do not match the upper case domain details
UPDATE ResourceKey SET KeyValue = upperUPPER(GWU.UserId) + '.' + upperUPPER(GWU.Domain)
fromFROM Inv_Global_Windows_Users GWU 
WHERE
	GWU._ResourceGuid = ResourceKey.ResourceGuid  AND 
	KeyName = 'name.domain'	AND 
	KeyValue <> (upperUPPER(GWU.UserId) + '.' + upperUPPER(GWU.Domain)) 
	AND NOT EXISTS (
		SELECT 1 FROM ResourceKey RKC 
		WHERE RKC.ResourceGuid = ResourceKey.ResourceGuid 
			AND KeyValue = upperUPPER(GWU.UserId) + '.' + upperUPPER(GWU.Domain))