Probably the simplest and most straightforward way is to create a calendar table and join with that table. Create the calendar table with two columns, one for the date and the other for the hours - like shown belowCREATE TABLE #Calendar(dt DATETIME, hourstoInsert INT);
Now populate this table for the date ranges that are of interest to you - for example, to do this for all of 2012, you would do the following:;WITH N(n) AS
(
SELECT 1 UNION ALL SELECT n + 1
FROM N
WHERE n < 366
)
INSERT INTO #Calendar
SELECT DATEADD(dd, n -1, '20120101'), 23
FROM N
OPTION(MAXRECURSION 0);I inserted 23 for all hours, you can run an update to change that to 22 for the dates of your interest.
Once you have this table, insert into your destination table by selecting from this table