日期:2014-05-16  浏览次数:20575 次

动态sql创建游标(sql server数据库)
http://blog.sina.com.cn/s/blog_561ef93d010001yt.html


/*********************************************/
--动态sql生成游标的示例  sql server数据库
/*********************************************/
Declare @mysql nvarchar(100) 
Declare @mysql2 nvarchar(100) 
declare @index bigint
SET @mysql = 'select Indx from bss_order' 
set @mysql2 = ' declare cur_test cursor for ' + @mysql
exec(@mysql2)
open cur_test
fetch next from  cur_test into @index
close cur_test
deallocate cur_test
select @index