1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
CREATE PROCEDURE UpdateECPC @camp_id varchar(20) AS BEGIN SET NOCOUNT ON DECLARE @lead_sum int DECLARE @page_views int SET @lead_sum = (SELECT SUM(lead_value) FROM Table_A WHERE camp_id = @camp_id) SET @page_views = (SELECT page_views FROM Table_B WHERE camp_id = @camp_id) UPDATE Table_C SET lead_eCPC = @lead_sum / @page_views WHERE camp_id = @camp_id SET NOCOUNT OFF END