• Nice DDL Trigger on the create database however you can avoid the cross join to sys.databases by using the following query:

    SELECT DATEADD(DD,N,dateadd(dd, 0, DATEDIFF(dd, 0, getdate()))) AS backupdate,

    DATENAME(DW,DATEADD(DD,N,dateadd(dd, 0, DATEDIFF(dd, 0, getdate())))) AS Backupweekday

    ,@DBName

    ,CASE WHEN N % 14 = 0 THEN 'F' ELSE 'D' END AS backuptype

    FROM dbo.Tally AS a

    WHERE N < 780

    Makes no difference in the long run im just personally a fan of shortening code.

    As far as the stored procedure goes, most people around here cringe when they see DECLARE CURSOR however i think those who do will also agree this is one of the few cases where you have to use the cursor. The other thing i may look into is a TRY CATCH block for error handling so if one backup fails it does not take out the rest and you can log the failure into a table or have an email alert generated by using something like sp_send_dbmail. It also looks like you went and read Jeff Moden's article on tally tables, if you did not find it here is the link http://www.sqlservercentral.com/articles/T-SQL/62867/ Its a really good read.

    The one thing i would suggest though is to move the backup schedule out of the master database and into a utility or tools database. again personal pet peve of any sort of user generated data in the system databases.


    For faster help in answering any problems Please read How to post data/code on a forum to get the best help - Jeff Moden[/url] for the best way to ask your question.

    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]