Maybe the "other" joins are giving you grief, but You sould be able to directly update the data. Here is a sample for doing a direct update and looping. DECLARE @Table1 TABLE(sitecode int, year int, month int, utilityusage int)DECLARE @Table2 TABLE (sitecode int, year int, month int, utilityusage int)DECLARE @Table3 TABLE (id int IDENTITY(1,1), sitecode int, year int, month int, utilityusage int)INSERT @Table1SELECT 1001, 1991, 2, 10UNION ALL SELECT 1001, 1991, 3, 12UNION ALL SELECT 1002, 1993, 4, 15UNION ALL SELECT 1003, 1993, 7, 7 UNION ALL SELECT 1004, 1993, 8, 10INSERT @Table2SELECT 1001, 1991, 2, 15UNION ALL SELECT 1001, 1991, 3, 12UNION ALL SELECT 1002, 1993, 4, 15UNION ALL SELECT 1003, 1993, 7, 7UNION ALL SELECT 1004, 1993, 8, 15 ---- Direct UpdateUPDATE T1SET T1.utilityusage = T2.utilityusageFROM @Table1 AS T1INNER JOIN @Table2 AS T2 ON T1.sitecode = T2.sitecode AND T1.year = T2.year AND T1.month = T2.monthWHERE T1.utilityusage <> T2.utilityusage-- Looping Method -- Load values that are differentINSERT @Table3SELECT T2.*FROM @Table1 AS T1INNER JOIN @Table2 AS T2 ON T1.sitecode = T2.sitecode AND T1.year = T2.year AND T1.month = T2.monthWHERE T1.utilityusage <> T2.utilityusageDECLARE @ID INTDECLARE @SiteCode INTDECLARE @Year INTDECLARE @Month INT-- Get the first item to work onSELECT @ID = MIN(id)FROM @Table3WHILE @ID IS NOT NULLBEGIN -- Get the data for calling teh stored procedure SELECT @SiteCode = sitecode, @Year = year, @Month = month FROM @Table3 WHERE id = @ID -- Call the stored procedure to do the work. -- EXEC MyStoredProcedure (Params go here) -- Remove the item just processed. DELETE @Table3 WHERE ID = @ID -- Get next item SELECT @ID = MIN(id) FROM @Table3END
EDIT: Added some more comments