well to generate the table here is a faster and more direct way. it uses a tally table to generate the dates (posted as a cte Tally Table). of course since it just uses a modulo function on N it will kinda break tomorrow so you will just have to adjust it slightly if you run it tomorrow.
;WITH cteTally (N) AS (SELECT 0 UNION ALL
SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL))
FROM (VALUES (0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) a(n)
CROSS APPLY (VALUES (0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) b(n)
CROSS APPLY (VALUES (0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) c(n))
--INSERT INTO DBO.backupschedule(backupdate, Backupweekday, database_name, backuptype)
SELECT DATEADD(DD,N,'2012-11-12') AS backupdate,
DATENAME(DW,DATEADD(DD,N,'2012-11-12')) AS Backupweekday,
'MyDatabase' AS database_name,
CASE WHEN N % 14 = 0 THEN 'F' ELSE 'D' END AS backuptype
FROM cteTally AS A
WHERE N < 366
As far as why you are generating this calendar table i would like some more info on that.
For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw[/url]
Need to Split some strings? Jeff Moden's DelimitedSplit8K[/url]
Jeff Moden's Cross tab and Pivots Part 1[/url]
Jeff Moden's Cross tab and Pivots Part 2[/url]