2
尽管在将它传递给sp_executesql时声明了一个类型为“cursor”的变量,但我得到错误“操作数类型冲突:nvarchar与游标不兼容”。是否可以将游标变量传递给sp_executesql?
declare CURSOR_TO_PASS cursor for... --a simple select statement
--cursor opened, values obtained, etc...
declare @item nvarchar(5);
declare @seqno int;
[email protected] and @seqno populated
declare @sql nvarchar(400) = N'update MYTABLE set Survey' + cast(@seqno as nvarchar(2)) + N' = @itemvalue where current of @sc';
exec sp_executesql @sql, N'@itemvalue nvarchar(5), @sc cursor', @itemvalue = @item, @sc = CURSOR_TO_PASS;
我不知道什么是错的,因为我已经宣布@sc作为一个光标,CURSOR_TO_PASS是一个光标,这我指定调用sp_executesql的时候@sc。那么,是否可以将光标传递给sp_executesql?