Professional Web Applications Themes

HELP: SQL script to backup all databases - Microsoft SQL / MS SQL Server

I would greatly appreciate some help, or a point in the right direction, please. I am new to MS SQL Server administration, and specifically scripting for MS SQL Server. I want to create a SQL script that would list the names of all databases to a text file, then I want to use a loop-statement to backup every database in the text file by using the SQL command: BACKUP DATABASE <name> TO DISK. Thus, the script would look something like this: ----- SNIP: Begin Script ----- [some sql command to export all database names to text file] read <dbname_from_text_file> while ...

  1. #1

    Default HELP: SQL script to backup all databases

    I would greatly appreciate some help, or a point in the right
    direction, please. I am new to MS SQL Server administration, and
    specifically scripting for MS SQL Server.

    I want to create a SQL script that would list the names of all
    databases to a text file, then I want to use a loop-statement to
    backup every database in the text file by using the SQL command:
    BACKUP DATABASE <name> TO DISK. Thus, the script would look something
    like this:

    ----- SNIP: Begin Script -----

    [some sql command to export all database names to text file]

    read <dbname_from_text_file>
    while [not_end_of_text_file]
    use <dbname_from_text_file>
    go
    backup database <dbname_from_text_file>
    to disk = 'dbname_file_to_dump_db_to'
    go
    read <dbname_from_text_file>
    end_while

    ----- SNIP: Begin Script -----


    In advance, thank you for your help.

    Cameron




    ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
    [url]http://www.newsfeed.com[/url] The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
    NoSpam Guest

  2. #2

    Default Re: SQL script to backup all databases

    instead of doing this you can use "Database Maintenance Plan Wizard". Open
    Enterprise manager | Tools | Database maintenance Planner.
    This wizard has option to create database maintenance plan to backup all of
    your databases on the server.

    You can get more help on this in BOL.Search on the topic "Database
    Maintenance Plan Wizard"

    --
    -Vishal

    "NoSpam" <nospamnospam.com> wrote in message news:3f0c61b0_1127.0.0.1...
    > I would greatly appreciate some help, or a point in the right
    > direction, please. I am new to MS SQL Server administration, and
    > specifically scripting for MS SQL Server.
    >
    > I want to create a SQL script that would list the names of all
    > databases to a text file, then I want to use a loop-statement to
    > backup every database in the text file by using the SQL command:
    > BACKUP DATABASE <name> TO DISK. Thus, the script would look something
    > like this:
    >
    > ----- SNIP: Begin Script -----
    >
    > [some sql command to export all database names to text file]
    >
    > read <dbname_from_text_file>
    > while [not_end_of_text_file]
    > use <dbname_from_text_file>
    > go
    > backup database <dbname_from_text_file>
    > to disk = 'dbname_file_to_dump_db_to'
    > go
    > read <dbname_from_text_file>
    > end_while
    >
    > ----- SNIP: Begin Script -----
    >
    >
    > In advance, thank you for your help.
    >
    > Cameron
    >
    >
    >
    >
    > ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet
    News==----
    > [url]http://www.newsfeed.com[/url] The #1 Newsgroup Service in the World! >100,000
    Newsgroups
    > ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
    =---


    Vishal Parkar Guest

Similar Threads

  1. Help with backup script on DW site panel.
    By stevenlmas in forum Macromedia Exchange Dreamweaver Extensions
    Replies: 1
    Last Post: February 24th, 04:03 AM
  2. Replies: 1
    Last Post: October 9th, 12:49 PM
  3. script to take backup
    By suhailh@yahoo.com in forum AIX
    Replies: 9
    Last Post: August 23rd, 09:50 AM
  4. udb backup script
    By sathyaram_s in forum IBM DB2
    Replies: 4
    Last Post: July 16th, 05:47 PM
  5. Replies: 2
    Last Post: July 5th, 11:12 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139