转自:http://www.maomao365.com/?p=6567

摘要:
下文讲述sql脚本模拟for循环的写法,如下所示:

 /*
for样例
for('初始值','条件','执行后自增')
通过对for语句的结构分析,我们可以采用以下
while 结构来实现for循环,
--------------------------
初始值
while(条件)
begin
  执行后自增
end
--------------------------
例:使用while输出10的遍历
*/
declare @i int=1  --初始值
while (@i<=10) --条件
begin
  print '@i的值:'
  print @i
  set @i=@i+1 ---执行后自增
end

 

相关文章:

  • 2022-01-15
  • 2021-10-24
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
  • 2021-12-15
  • 2021-09-08
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
  • 2021-08-08
相关资源
相似解决方案