首页 > 代码库 > sql server 循环

sql server 循环

USE pubs
Go
WHILE (SELECT AVG(price) FROM titles) < $30
BEGIN
   UPDATE titles
      SET price = price * 2
   SELECT MAX(price) FROM titles
   IF (SELECT MAX(price) FROM titles) > $50
      BREAK
   ELSE
      CONTINUE
END


------------------------------------------------------

设置个变量,就能实现for(i=0;i<10,i++DECLARE @i int
set @i=0

WHILE @i<10
BEGIN
//语句序列
   ...
   set @i=@i+1
END

使用go
go
 select * from AYS_XZ_MEETINGROOM
go 200

 

sql server 循环