ALTER PROCEDURE [dbo].[B_OF_DATA_PLA]
AS
BEGIN
-- 声明变量
DECLARE @Value1 nvarchar(100),@Value2 datetime,@Value3 datetime
-- 定义游标
DECLARE cE_OF CURSOR FOR
SELECT E_NOF,E_OF_DATE_DEB_PLA,E_OF_DATE_FIN_PLA
FROM E_OF
WHERE E_ETATOF != 'O'
AND E_OF_DATE_DEB_PLA IS NOT NULL AND E_OF_DATE_FIN_PLA IS NOT NULL
-- 打开游标
OPEN cE_OF
-- 取出第一条
FETCH NEXT FROM cE_OF INTO @Value1,@Value2,@Value3
-- 循环
WHILE @@FETCH_STATUS = 0
BEGIN
UPDATE B_OF
SET DPLUSTOT = @Value2,FPLUSTARD = @Value3
WHERE ETATOF != 'O' AND NOF = @Value1
-- 获取下一条记录
FETCH NEXT FROM cE_OF INTO @Value1,@Value2,@Value3
END
CLOSE cE_OF
DEALLOCATE cE_OF
END
标签:--,游标,cE,Server,Value3,Value2,PLA,SQL
From: https://www.cnblogs.com/nullcodeworld/p/18184827