declare Fetch1 Cursor for
   select aa,@birthField from A001
   open Fetch1

解决方案 »

  1.   

    declare @sql varchar(8000)
    set @sql='declare Fetch1 Cursor for
    select aa,'+@birthField+' from A001'
    exec(@sql)
    open Fetch1
      

  2.   

    动态游标!
    declare @sql varchar(8000)
    set @sql='declare Fetch1 Cursor for
    select aa,'+@birthField+' from A001'
    exec(@sql)
    open Fetch1
    fetch next from Fetch1
    close Fetch1
    deallcate Fetch1
      

  3.   

    Exec('declare Fetch1 Cursor for select aa,'+@birthField+' from A001')
       open Fetch1
      

  4.   

    declare Fetchl Cursor for
        select birthField from A001           -----(1)
    open Fetchl
    fetch next from Fetchl into @birthField    ----(2)(1)和(2)处的参数个数相同,从(1)处查出的字段存到(2)中对应的变量中