
ALTER TABLE TMemberCourse ADD FOldExpiredDate DATETIME NULL

UPDATE TMemberCourse SET FOldExpiredDate = FExpiredDate 

DROP TABLE #Course
SELECT * INTO #Course FROM TMemberCourse WHERE FBizType = 'DR.Import'
WHERE DATEADD(y,FPurchaseDate,FExpiredDate) < 1

SELECT * FROM TMemberCourse WHERE FBizType = 'DR.Import'
AND DATEDIFF(y,FPurchaseDate,FExpiredDate) < 1

SELECT FMemId,FCourseId,FPurchaseDate,FExpiredDate,DATEDIFF(day,FPurchaseDate,FExpiredDate)
 FROM #Course
WHERE DATEDIFF(day,FPurchaseDate,FExpiredDate) < 360



UPDATE #Course SET FExpiredDate = DATEADD(year,1,FPurchaseDate)
WHERE DATEDIFF(day,FPurchaseDate,FExpiredDate) <= 31
WHERE DATEDIFF(day,FPurchaseDate,FExpiredDate) > 366


SELECT * FROM TMember WHERE FMemId = 6156043197183955340


SELECT * FROM TmemberCourse
WHERE DATEDIFF(day,FPurchaseDate,FExpiredDate) < 360

SELECT DATEDIFF(day,FPurchaseDate,FExpiredDate),* FROM #Course 
WHERE DATEDIFF(day,FPurchaseDate,FExpiredDate) < 360

UPDATE A
   SET A.FExpiredDate = B.FExpiredDate
 FROM #Course AS B,TMemberCOurse AS A
WHERE A.FId = B.FId


UPDATE A
   SET A.FExpiredDate = B.FExpiredDate
 FROM #Course AS A,TMemberCard AS B,TMember AS M
WHERE A.FMemId = B.FMemId
AND B.FMemId =A.FMemId
AND B.FCardNo = M.FMemNo 
AND A.FPurchaseDate = B.FCreateDate

UPDATE 

SELECT * FROM TMemberCard WHERE FMemId = 7713729641189473441

SELECT * FROM TImportConfig#

USE s3_jinan_8JINZHI6aykoc

SELECT * FROM TMemberCard WHERE DATEDIFF(day,FCreateDate,FExpiredDate) > 366

