日期:2014-05-17 浏览次数:20554 次
update 用户表
set 用户表.scores=积分表.scores
from 用户表 inner join 积分表 on 积分表.User_ID=用户表.User_ID
where 积分表.flagpay='未发放' and CONVERT(DATETIME,CONVERT(VARCHAR(20),DateTake ,121))<getdate()
GO
WITH tb
AS ( SELECT USER_ID ,
Score
FROM 积分表
WHERE DateTake < CONVERT(DATE, GETDATE())
AND FlagPay = 0
)
UPDATE 用户表
SET 用户表.Score = 用户表.Score + tb.Score
FROM tb
WHERE 用户表.USER_ID = tb.USER_ID