比如游标1
求出表中的值s1,s2当s1,s2满足一定条件时
删除表中的这条纪录该怎么做啊?为什么我用
delete table where current of cursor_t
删除不了呢?

解决方案 »

  1.   

    可能是游标类型不对
    create table #a(a varchar(10))
    insert #a select 'a' union all select 'b' union all select 'a' union all select 'b' union all select 'c'
    -----------------------------------------------------------
    declare a cursor local scroll_locks for select * from #a 
    open a
       declare @b varchar(10)
       fetch a into @b
       while (@@fetch_status=0)
       begin
          if @b='b'
          delete #a where current of a
          fetch a into @b
       end
    close a    
    deallocate a
    ------------------------------------------------------------
    select * from #a
      

  2.   

    fetch ABSOLUTE @i from cursor_t
    这是不是取表中的第@i条纪录?
      

  3.   

    服务器: 消息 16911,级别 16,状态 1,过程 pro_TestTuples,行 33
    fetch: 提取类型 absolute 不能用于只进游标。但是不用只进游标又会出现这种服务器: 消息 16929,级别 16,状态 1,过程 pro_TestTuples,行 46
    游标是 READ ONLY 的。
    该怎么办啊?