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?