update tApprovalSchemaItem set iApprovalSchemaItemOrder=ord 
from tApprovalSchemaItem i 
join (select ROW_NUMBER() over (partition by liApprovalSchemaItemApprovalSchemaId order by iApprovalSchemaItemOrder, iApprovalSchemaItemId) as ord, iApprovalSchemaItemId from tApprovalSchemaItem) o on i.iApprovalSchemaItemId=o.iApprovalSchemaItemId
