Update HRM_User
Set
GroupEnumItemCode = (Select TOP 1 Code From BDC_EnumItem Where Code LIKE (Select CodePre From BDC_EnumSpec Where Code = 'PPM_ProduceGroup')+'%' and IsDefault = '1' Order By Code)
Where
1=1
and GroupEnumItemCode = '' OR LEN(GroupEnumItemCode)<7 OR (GroupEnumItemCode = (Select TOp 1 Code From CRM_CustomerGroupSpec Order By Code ASC))
and ((Select TOP 1 Code From BDC_EnumItem Where Code LIKE (Select CodePre From BDC_EnumSpec Where Code = 'PPM_ProduceGroup')+'%' and IsDefault = '1' Order By Code)) IS NOT NULL
GO