I have the following Query I have been staring at for a long time and can't figure out what is wrong with it. The compiler says the error is near the "ELSE" keyword but I can't see a problem there.
IF EXISTS (SELECT 1 FROM table1 WHERE Period = @CurrentPeriod AND Acct = @Acct)
UPDATE table1 SET Amount = Amount + @TotalAmount, TotalCostInput = Amount + @TotalAmount
WHERE (DO LIKE @ProjectName + '%') AND (Revision LIKE @Revision + '%') AND (Task LIKE @WBS + '%') AND (Period = @CurrentPeriod) AND (Acct <> 'Direct Labor')
ELSE INSERT INTO table1 (DO, Task, TTitle, Hours, Period, Year)
SELECT @ProjectName, @WBS, @WBSTitle, @Hours, @CurrentPeriod, @ThisYear
WHERE NOT EXISTS(SELECT NULL FROM table1 WHERE Period = @CurrentPeriod AND Acct = @Acct)