아래와 같은 업데이트 쿼리가 있습니다. 누군가가 두 번째의 경우, 어떻게이 문제를 자동화하는주어진 SQL 쿼리를 자동화하는 방법
1)I have to execute First part.
2)Then comment line "AND s.ExtractYear = l.ExtractYear"...
3)Uncomment "--and l.ExtractYear = 2011" and "--WHERE s.Prod IS NULL", then execute.
4)Uncomment "--and l.ExtractYear = 2010" and "--WHERE s.Prod IS NULL", then execute.
5)Uncomment "--and l.ExtractYear = 2009" and "--WHERE s.Prod IS NULL", then execute.
6)Uncomment "--and l.ExtractYear = 2008" and "--WHERE s.Prod IS NULL", then execute.
7)Uncomment "--and l.ExtractYear = 2007" and "--WHERE s.Prod IS NULL", then execute.
--First part
UPDATE s
Set Col1 = value
FROM table1 s
INNER JOIN LkpTable l
ON
s.PId= l.PId
AND s.ExtractYear = l.ExtractYear
--Second part
--and l.ExtractYear = 2011
--and l.ExtractYear = 2010
--and l.ExtractYear = 2009
--and l.ExtractYear = 2008
--and l.ExtractYear = 2007
--WHERE s.Prod IS NULL
* * 쿼리 및 그 희망을 분명히해야합니다. –
'value'는 쿼리 수정 시마다 동일하거나 다를 것입니까? –