本帖最后由 totola147 于 2012-04-12 10:45:26 编辑

解决方案 »

  1.   


    create proc pro_test
    @aa int
    as
    while @aa>10
    beging
    set @aa=@aa+10
    end
    else
    begin
    end
    --你应该是退出循环吧,使用while循环就好了
      

  2.   

    退出循环的方法我会  不过还是谢谢哈  办法找到了  return
      

  3.   

    用return跳出整个循环,用continue跳出单循环
      

  4.   

    create proc pro_test
    @aa int
    as
    set @aa=@aa+10
    if @aa>10
    终止此存储过程 (这里应该如何写,exit不行)
    else
    begin
    ...
    end要终止存储过程,直接在if @aa>10后面写end 就行了吧?
      

  5.   

    不对,是用return
    你写个存储过程测试一下
    这是我的测试过程
    create proc pro_test
    @aa int
    as
    if @aa>10
    begin
    print '大于10时'
    return
    end
    else
    begin
    print '小于10时'
    end
    print '全部执行完后结束'exec pro_test 1
    exec pro_test 11
      

  6.   

    跳出循环用break  
    我狂汗另外 在T-SQL中循环只能使用while condition 所以想跳出了 ,修改condition 为false不就行了
    我是没有想到 break 有什么用 continue 还有用一点