You can do that, but IF is control flow and not part of a SQL statement, hence you must put complete insert statements within the IF blocks
IF @PeriodType = 'Monthly'
BEGIN
INSERT INTO Monthly_Summary_Data (Column_1, Column_2, etc.)
SELECT (Value_1, Value_2, etc.)
FROM SourceTable
END
IF @PeriodType = 'Daily'
BEGIN
INSERT INTO Daily_Summary_Data (Column_1, Column_2, etc.)
SELECT (Value_1, Value_2, etc.)
FROM SourceTable
END
I don't want to have to duplicate the code in the SELECT statement for each of the period types as this would be a pain to maintain.
You'll have to, unless you want to do some really stupid stuff with dynamic SQL.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability