begin tran

declare @commisionIDList table(commisionID uniqueidentifier)

insert into @commisionIDList
select distinct remoteId from [user].userRelation where remoteSource = 'commisionService'

declare @currentCommisionID uniqueidentifier

while exists(select * from @commisionIDList) BEGIN
	select top 1 @currentCommisionID = commisionID from @commisionIDList

	exec wms.commision_updateResponsiblePeopleFullTextIDs @commisionID = @currentCommisionID

	delete from @commisionIDList where commisionID = @currentCommisionID

end

rollback tran
