动态游标
2007-11-11 10:34:08 来源:WEB开发网核心提示: 舉個例子,你再根據你的具體情況進行修改:declare @sqlExec varchar(8000),@tableName varchar(255) set @tableName = 'sysobjects'
舉個例子,你再根據你的具體情況進行修改:
declare @sqlExec varchar(8000),@tableName varchar(255)
set @tableName = 'sysobjects'
set @sqlExec = 'declare cursor1 cursor for ' + CHAR(13)
set @sqlExec = @sqlExec + ' select * from ' + @tableName
exec(@sqlExec)
open cursor1
fetch next from cursor1 ---如果要放在变量中请写into <变量列表>
while @@fetch_status = 0
......
fetch next from cursor1 ---如果要放在变量中请写into <变量
end
close cursor1
deallocate cursor1
更多精彩
赞助商链接