automatically backup new created database once

Last post 12-28-2007 5:29 AM by dineshasanka. 6 replies.
Page 1 of 1 (7 items)
Active Topics My Discussions Unanswered Sort Posts: Previous Next
  • 12-26-2007 1:36 PM

    automatically backup new created database once

    Hi,

    I've sql 2005 std sp2,and i'm working with a program that create every view month's a new database automatically. 

    my question is - how can i make a full backup of the newly created database automatically only one time when it's created?

    Thx

    There is always something new to learn...
  • 12-27-2007 12:48 AM In reply to

    • martins
    • Top 75 Contributor
    • Joined on 08-06-2007
    • South Africa
    • Posts 258

    Re: automatically backup new created database once

    Hi,

    I am using SQL2k, so I don't know if there is a better way in SQL2k5...

    In the master database there is a table called sysdatabases, which has a field crdate that tells you when a database was ceated. You can schedule a job that runs every night and query this database to see if any databases were created during that day...and of course then perform a full backup on that database.

  • 12-27-2007 1:10 AM In reply to

    Re: automatically backup new created database once

     Hi,

    you may schedule the job as Martin suggested, i.e. schedule a job which take full backup on 1st of every month;

     

    Hemantgiri S. Goswami | MS SQL Server MVP
    -------------------------
    "Humans don't have Caliber to PASS TIME , Time it self Pass or Fail Humans" - by Hemantgiri S. Goswami

    http://hemantgirisgoswami.blogspot.com
    http://forums.surat-user-group.org/

    View Hemantgiri S. Goswami's profile on LinkedIn

    Disclaimer: This post is provided as is, for the sake of knowledge sharing only.
  • 12-27-2007 2:11 AM In reply to

    • jn4u
    • Top 500 Contributor
    • Joined on 01-19-2005
    • Sweden
    • Posts 67

    Re: automatically backup new created database once

     

    Understand you are using a dot net program to make the database? Or is schedule sql? If it’s a program I would start using SMO. Just after calling the “create database”. Check this article.

    http://www.sqldbatips.com/showarticle.asp?ID=37

    I have used is for some solutions like it better the trie to make program logic in sql.

     

  • 12-28-2007 5:21 AM In reply to

    Re: automatically backup new created database once

    can anyone point me how to start the tsql statement to achieve this backup new created database.

    Thx

    There is always something new to learn...
  • 12-28-2007 5:24 AM In reply to

    • martins
    • Top 75 Contributor
    • Joined on 08-06-2007
    • South Africa
    • Posts 258

    Re: automatically backup new created database once

    You will have to write dynamic sql to insert the database name retrieved from the system tables into the backup statement. Read up on backup statements and dynamic sql in BOL, and you should find enough information to write it.

  • 12-28-2007 5:29 AM In reply to

    Re: automatically backup new created database once

    You can add a Server DDL trigger for Database Creation to create database backup

    Contributing Editor, Writer & Forums Moderator http://www.SQL-Server-Performance.Com

    Visit my Blog at http://dineshasanka.spaces.live.com/

    View Dinesh Asanka's profile on LinkedIn
Page 1 of 1 (7 items)
Active Topics   My Discussions    Unanswered Posts


© 2000 - 2007 vDerivatives Limited All Rights Reserved.