方法一:
不知道多輸出參數如何寫:
declare @cursor_name varchar(36),@str nvarchar(4000)
select @cursor_name=newid()
DECLARE @ckbm varchar(20)
exec(''DECLARE [''+@cursor_name + ''] CURSOR FOR select f_ckbm from tbda_ck'')
exec(''open [''+ @cursor_name+'']'')
set @str=N''fetch from [''+ @cursor_name +''] into @ckbm''
exec sp_executesql @str,N''@ckbm varchar(20) out'',@ckbm out
while @@fetch_status = 0
begin
print @ckbm
exec sp_executesql @str,N''@ckbm varchar(20) out'',