update mscrm_config.dbo.systemuser set mscrm_config.dbo.systemuser.defaultorganizationid =
(select sub.organizationid from systemuserbase sub,
mscrm_config.dbo.systemuserorganizations csuo
where sub.systemuserid = csuo.crmuserid and
csuo.userid = mscrm_config.dbo.systemuser.id)
where 1 =
(select count(*) from systemuserbase sub,
mscrm_config.dbo.systemuserorganizations csuo
where sub.systemuserid = csuo.crmuserid and
csuo.userid = mscrm_config.dbo.systemuser.id and
sub.domainname = 'domain\username')