控制流语句:
1 begin .....end  
2 if ...else  例如:if exists (select * from 表名称 ) begin selct * from  表名称 end 
3 while  break countinue
while语句用于设置重复执行的sql语句或者语句块
continue语句可以让语句跳过contunue 语句之后的语句回到while循环的第一行
break语句则让程序完全跳出循环结束while循环的执行。

例如:

declare @a int 
declare @b int 
set @a=1
set @b=0
while(@a<=100)
begin 
set  @b=@b+@a
set @a=@a +1
end
print @b

  

相关文章:

  • 2022-12-23
  • 2022-02-18
  • 2022-12-23
  • 2021-05-29
  • 2021-06-16
猜你喜欢
  • 2021-10-22
  • 2022-02-27
  • 2022-12-23
  • 2021-11-02
  • 2021-06-21
  • 2021-06-09
相关资源
相似解决方案