DECLARE @MyCursor CURSOR
------
???

解决方案 »

  1.   

    Transact-SQL 扩展语法
    DECLARE cursor_name CURSOR 
    [ LOCAL | GLOBAL ] 
    [ FORWARD_ONLY | SCROLL ] 
    [ STATIC | KEYSET | DYNAMIC | FAST_FORWARD ] 
    [ READ_ONLY | SCROLL_LOCKS | OPTIMISTIC ] 
    [ TYPE_WARNING ] 
    FOR select_statement 
    [ FOR UPDATE [ OF column_name [ ,...n ] ] ]cursor_name是所定义的 Transact-SQL 服务器游标名称。cursor_name 必须遵从标识符规则。只能使用常数,要使用变量可以用动态SQL.
      

  2.   

    如果要用变量,改用:exec('declare '+@cursormdl|' cursor for sql_statment')
      

  3.   

    --创建
    create procedure test
    as
    declare @test cursor 
    SET @test = CURSOR FOR
    SELECT * FROM sysobjects
    open @test
    fetch next from @test
    close @test
    deallocate @test
    go
    --调用
    exec test