还有一个8在这
fetch next from myCursor into @a1     
     print @a1

解决方案 »

  1.   

    declare myCursor cursor 
     for select column1 from textTable
     open myCursor
     declare @a1 int 
     fetch next from myCursor into @a1 
     print @a1 
    while @@fetch_status =0
    begin
         print @a1 
         fetch next from myCursor into @a1          
    end
     close myCursor
     deallocate myCursor
      

  2.   

    --try
    declare myCursor cursor 
     for select column1 from textTable
     open myCursor
     declare @a1 int 
     fetch next from myCursor into @a1 
     print @a1 
    while @@fetch_status =0
    begin
         print @a1  
         fetch next from myCursor into @a1     
    end
     close myCursor
     deallocate myCursor
      

  3.   

    open myCursor
     declare @a1 int 
     fetch next from myCursor into @a1 
    while @@fetch_status =0
    begin
         print @a1 
         fetch next from myCursor into @a1      
    end
    这样看看
      

  4.   

    如果这样:
         print @a1  
         fetch next from myCursor into @a1 
    答案就是:
    2
    2
    4
    6
    8
    -------------------------------------------
    这回8是读了一次,但2读了两次,
      

  5.   

    declare myCursor cursor 
     for select column1 from textTable
     open myCursor
     declare @a1 int 
    你思路不对,应是先判断是否取得数据,如取得数据则打印出来。所以稍改动如下: fetch next from myCursor into @a1 
     
    while @@fetch_status =0
    begin
    print @a1 
         fetch next from myCursor into @a1     
          
    end
     close myCursor
     deallocate myCursor
      

  6.   

    --你思路不对,应是先判断是否取得数据,如取得数据则打印出来。所以稍改动如下:
    declare myCursor cursor 
     for select column1 from textTable
     open myCursor
     declare @a1 int 
     fetch next from myCursor into @a1 
     
    while @@fetch_status =0
    begin
    print @a1 
         fetch next from myCursor into @a1     
          
    end
     close myCursor
     deallocate myCursor