BEGIN
DECLARE @SAPHINMEICD VARCHAR(20);
DECLARE @NEWHINMEICD VARCHAR(20);
DECLARE @UPCOUNT INT ;
DECLARE curSekDt CURSOR FOR
SELECT
[SAPHINMEICD]
,[NEWHINMEICD]
FROM [dbo].[M_HINMEI_ERA]
SET @UPCOUNT = 0
OPEN curSekDt
-- FETCH
FETCH NEXT FROM curSekDt INTO
@SAPHINMEICD,
@NEWHINMEICD
WHILE @@FETCH_STATUS = 0
BEGIN
UPDATE [M_HINMEI] SET TOKUHINMCD = @SAPHINMEICD
WHERE TOKUHINMCD = @NEWHINMEICD;
SET @UPCOUNT =@UPCOUNT + 1
PRINT CAST(@UPCOUNT AS VARCHAR) + ': ' + @NEWHINMEICD + ' ⇒ ' + @SAPHINMEICD
+ '('+ CAST(@@ROWCOUNT AS VARCHAR) + ')'
FETCH NEXT FROM curSekDt INTO
@SAPHINMEICD,
@NEWHINMEICD
END
CLOSE curSekDt
DEALLOCATE curSekDt
END