T-SQL中如何声明一个带参数的游标?
CURSOR CUR1(yyyyMM CHAR(6))
------------------------------------
SELECT
CD_SHIHARAI
FROM
T_N012
WHERE
TD_DELETE IS NULL
AND YM_SHIHARAI = yyyyMM
------------------------------------
如上边所写的,声明一个CURSOR,name:CUR1,需要传入一个参数,作为查询条件(SELECT文最后一行),譬如参数name:yyyyMM,type:CHAR(6),请教这样的游标怎么写?谢谢!
------解决方案--------------------declare @yyyyMM varchar(6)
set @yyyyMM = '?????? '
declare CUR1 cursor for SELECT CD_SHIHARAI FROM T_N012 WHERE TD_DELETE IS NULL AND YM_SHIHARAI = @yyyyMM
...