一.流程控制语句 1.分支结构 IF分支: IF 条件1 THEN 语句;ELSEIF 条件2 THEN 语句; ......ELSE 语句;END IF; CASE分支: CASE [条件] WHEN 条件1 THEN 语句1WHEN 条件2 THEN 语句2 ......ELSE 语句nEND CASE 2.循环结构 LOOP循环: [begin_label:] LOOP 语句群END LOOP [end_label] WHILE语句: [begin_label:] WHILE 条件 DO
Declare myCursor cursor For Select * from table1 open myCursor Fetch next From myCursor into @变量 While @@FETCH_STATUS =0 begin --处理单条记录 Fetch next From myCursor end Close