USE pubs
GO
DECLARE authors_cursor CURSOR FOR
SELECT au_lname FROM authors
WHERE au_lname LIKE 'B%'
ORDER BY au_lnameOPEN authors_cursor-- Perform the first fetch.
FETCH NEXT FROM authors_cursor-- Check @@FETCH_STATUS to see if there are any more rows to fetch.
WHILE @@FETCH_STATUS = 0
BEGIN
   -- This is executed as long as the previous fetch succeeds.
   FETCH NEXT FROM authors_cursor
ENDCLOSE authors_cursor
DEALLOCATE authors_cursor
GO

解决方案 »

  1.   

    是不是遊標隻有一條記錄,應該說遊標有多少條,table_a就顯示多少次
      

  2.   


    open my_cursor
    FETCH NEXT FROM my_cursor
    WHILE @@FETCH_STATUS = 0
    BEGIN
      
    select * from tt1
     
    FETCH NEXT FROM my_cursor
    end結果:(影響 1 個資料列)
    (影響 3 個資料列)
    (影響 1 個資料列)
    (影響 3 個資料列)
    (影響 1 個資料列)
    (影響 3 個資料列)
    (影響 1 個資料列)
    (影響 3 個資料列)
    (影響 1 個資料列)
    (影響 3 個資料列)
    (影響 0 個資料列)
      

  3.   

    在查询分析器执行结果就象上面是
    如果写成存储过程
    exec pro_name
    就显示一次