游标
DECLARE cur1 CURSOR SCROLL FOR SELECT DISTINCT xxx,xxx,xxx FROM xxx WHERE xxx='xxx' ORDER BY xxx OPEN cur1 FETCH NEXT FROM cur1 INTO @xxx,@xxx,@xxx WHILE @@fetch_status=0 BEGIN -- sql FETCH NEXT FROM cur1 INTO @xxx,@xxx,@xxx END CLOSE cur1 DEALLOCATE cur1