• here's one i use... (just a shade faster than Julian's method  )

     

    declare @clientId int

    select ClientId into #ClientList from ...

    while 1=1

    begin

      select @clientId = min(ClientId) from #ClientList where ClientId > isnull(@clientId, -1)

      if @clientId is NULL break

    -- some code

    end

    however, using a cursor is sometimes more efficient than this method because it doesn't have to scan or seek the next ClientId (this method does (obviously it's not an issue if your list of ids is small))

     

    hope that helps.