我有一個更新查詢,如下所示。誰能告訴我如何自動執行此,請如何自動化給定的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
我不清楚你正在試圖與註釋和取消註釋等,到底該怎麼做,你能否告訴前三**完整* *查詢和應該明確希望。 – 2011-04-25 21:01:14
對於查詢的每個修改,「值」是相同的還是不同的? – 2011-04-25 21:48:18