游标

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

 

posted @ 2017-05-31 10:44  芈璐  阅读(127)  评论(0编辑  收藏  举报