Sql 循环
作者:互联网
declare --创建游标 cur cursor for select _user,_pwd from userTable; declare @use varchar(20),@pw varchar(20); begin --打开游标 open cur; --移动游标取值 fetch next from cur into @use,@pw; --这里对游标的状态进行判断,如果为0,证明游标中有值 while @@FETCH_STATUS = 0 begin print(@use); print(@pw); --让游标继续往后移动 fetch next from cur into @use,@pw end --关闭游标 close cur; deallocate cur; end
DECLARE @i INT = 0; --设置循环次数起始值 WHILE @i < 100 --200是循环终止次数 BEGIN print (@) SET @i = @i + 1; END;
标签:use,cur,--,游标,循环,Sql,print,pw 来源: https://www.cnblogs.com/happygx/p/16377636.html