2013-10-22 3 views
0

내가 말하고자하는 것은 다음과 같습니다. "RC.Expiration이 오늘 날짜보다 크거나 같고 RC.DemoLicense가 0과 같으면 DemoTracking.Purchased를 1로 설정합니다."DT 만 입력하면됩니다. 구매 0업데이트를 올바르게 사용하고 있습니까?

update WebCatalog.Published.DemoTracking 
set Purchased = 1 
from WebCatalog.Published.RCompany RC 
inner join WebCatalog.Published.DemoTracking DT 
    on RC.Link = DT.RCompanyLink and DT.Purchased = 0 
where RC.Expiration >= GETDATE() and RC.DemoLicense = 0 
+3

내가 where 절에'DT.Purchased = 0 '을 이동 것 시도이지만, 주관적, 그것은 어쨌든 동일하게 작동합니다. 언뜻보기에 쿼리가 올바르게 작동해야합니다. –

+2

GetDate()는 해당 날짜의 이전 레코드를 놓칠 수있는 datetime을 반환합니다. 이 문제를 해결하려면 getdate()를 날짜로 형변환하십시오. –

답변

0

이이

update WebCatalog.Published.DemoTracking 
set Purchased = 1 
where Purchased = 0 and RCompanyLink in (select Link as RCompanyLink from WebCatalog.Published.RCompany where RC.Expiration >= GETDATE() and RC.DemoLicense = 0) 
관련 문제