HELP: SQL script to backup all databases  
Author Message
AndersB





PostPosted: Wed Jul 09 14:26:09 CDT 2003 Top

SQL Server Developer >> 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==----
http://www.hide-link.com/ The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---

SQL Server224  
 
 
Vishal





PostPosted: Wed Jul 09 14:26:09 CDT 2003 Top

SQL Server Developer >> HELP: 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


> 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==----
> http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000
Newsgroups
> ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---