# batch job output file data is not in correct order



## willow123 (Feb 29, 2012)

HI,

I am new to this site, so i dont know where to post this question. please read completely below about my issue.

if (($database eq "master") or ($database eq "msdb") or ($database eq "model"))

{
print "Excluding system databases from performing Differential or log backups\n\n";

}

my $sqlserverconnectionstring = Win32::SqlServer::sql_init($servername,'mohan','mohan', 'master');
my $sqlstatement = <<SQLEND;
BACKUP database $database TO DISK = N'C:\\backup\\$database.bak'
SQLEND
my $result = $sqlserverconnectionstring->sql($sqlstatement, SCALAR);

when i execute this in command prompt, the output is :

Excluding system databases from performing Differential or log backups

Processed 1688 pages for database 'msdb', file 'MSDBData' on file 11.
Processed 5 pages for database 'msdb', file 'MSDBLog' on file 11.
BACKUP DATABASE successfully processed 1693 pages in 3.895 seconds (3.394 MB/sec).

when i put this in batch file 
batch file looks like this:
perl test.pl -d msdb -i localhost >> 1.sysout 2>&1

the output in 1.sysout is:

Processed 1688 pages for database 'msdb', file 'MSDBData' on file 5.
Processed 5 pages for database 'msdb', file 'MSDBLog' on file 5.
BACKUP DATABASE successfully processed 1693 pages in 1.702 seconds (7.768 MB/sec).

Excluding system databases from performing Differential or log backups

here in batch job its printing first sql server output and then print statement output

how to print same as like command prompt.

please let me if you have any questions


----------



## Squashman (Apr 4, 2003)

Please do not duplicate your posts into another category.
http://forums.techguy.org/windows-xp/1043145-batch-job-output-order-not.html


----------

