本帖最后由 xx_mm 于 2010-08-27 15:53:53 编辑

解决方案 »

  1.   

    比如表A(code varchar(50))我要循环A表中所有行,用while条件怎么写?
    不过大部分用游标的地方可以用多行处理来完成同样的功能。
      

  2.   

    declare @cou int
    declare @i int;
    set @i=0;
    while @i<@cou
    begin
    select top 1 from testtab where [id] not in (select top (@i) [id] from testtab);
    set @i=@i+1;
    end
      

  3.   

    错了,这样
    declare @cou int
    declare @i int;
    set @i=0;
    set @cou=(select count(*) from testtab );
    while @i<@cou
    begin
    select top 1 from testtab where [id] not in (select top (@i) [id] from testtab);
    set @i=@i+1;
    end