Re: Automating 'results to file' in script
From: Jacco Schalkwijk (jacco.please.reply_at_to.newsgroups.mvps.org.invalid)
Date: 08/07/04
- Next message: Aaron [SQL Server MVP]: "Re: Automating 'results to file' in script"
- Previous message: Hugo Kornelis: "Re: Set Rowcount Effect on Sub-Query"
- In reply to: Sydney Lotterby: "Automating 'results to file' in script"
- Next in thread: Aaron [SQL Server MVP]: "Re: Automating 'results to file' in script"
- Reply: Aaron [SQL Server MVP]: "Re: Automating 'results to file' in script"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 7 Aug 2004 23:09:38 +0100
For generating script files you might be better of using the osql command
line tool. You can specify a script (your statement) as the input file (-i
switch) and another file as the output file (-o switch). See Books Online
for the complete syntax and some examples.
However, if you want to backup all databases, you might want to have a look
at maintenance plans in SQL Server. They have an option to backup all
databases, or either all user databases or all system databases.
-- Jacco Schalkwijk SQL Server MVP "Sydney Lotterby" <sydney@infosearch.com> wrote in message news:Op4osjKfEHA.2544@TK2MSFTNGP10.phx.gbl... > (Sql2K) > In QA, I would like to automatically send the results of a script to a > filename. > Now I have to select 'Results to File' before I run the script then > specify > the filename afterwards. > Is there a way to do this? > > Or ... can you tell me a better way to do what I am trying (see below) > > declare @path varchar(128), @t char(1), @q char(1), @crlf char(2) > set @path = 'E:\MSSQL\MSSQL\BACKUP\DAILY\' > set @t = char(9) > set @q = '''' > set @crlf = char(13)+char(10) > > SELECT 'BACKUP DATABASE '+name+@t+ > 'TO DISK = '+@q+@path+'bu'+name+@q+@t+ > 'WITH INIT,'+@t+ > 'NAME = '+@q+'bu'+name+@q+ > @crlf+'GO' > from MASTER..sysdatabases > where name like 'isw%' > order by name > > > >
- Next message: Aaron [SQL Server MVP]: "Re: Automating 'results to file' in script"
- Previous message: Hugo Kornelis: "Re: Set Rowcount Effect on Sub-Query"
- In reply to: Sydney Lotterby: "Automating 'results to file' in script"
- Next in thread: Aaron [SQL Server MVP]: "Re: Automating 'results to file' in script"
- Reply: Aaron [SQL Server MVP]: "Re: Automating 'results to file' in script"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|