All, In an earlier post inquiring about how to get the results ( such as from a backup or dbcc ), rather than rows, the response pasted below indicated a solution.... however, when I try this, I find that the actual results are returning in STDERR, not in the variable $text....
In my code, I redirect STDERR to a file, as well as STDOUT... printing the variable always prints a null string... while the file containing the STDERR always has the results... This is the case if it's an error ( I forced one for a backup command )... or if it's just results ( I ran a simple dbcc checkdb )... If you look at the resolution code below... depending on how it was run, STDERR might have been what was seen, not the print of $text... Anyone have any clues on this one??.. Thanks, Louise Mitchell *********************************** >From archives ( 09-Sep-2003 ) *********************************** From: "Martin J. Evans" <[EMAIL PROTECTED]> > I haven't tried it in a long time (other than running make test) but > from perldoc DBD::ODBC: > > odbc_async_exec > Allow asynchronous execution of queries. Right now, > this causes a spin-loop (with a small "sleep") until > the sql is complete. This is useful, however, if you > want the error handling and asynchronous messages (see the > err_handler) below. See t/20SQLServer.t for an example of > this. Sweeeeet. It works: use DBI; my $text = ''; my $dbh = DBI->connect('dbi:ODBC:jobodbc2', 'TMPJOBVIPERADMIN', 'jobviper', {PrintError => 0,RaiseError => 1,LongReadLen => 65536, odbc_async_exec => 1, odbc_err_handler => sub { my ($state, $msg) = @_; # Strip out all of the driver ID stuff $msg =~ s/^(\[[\w\s]*\])+//; $text .= $msg."\n"; return 0; } }); $sth = $dbh->prepare("dbcc CHECKDB ('jobviper')"); $sth->execute; print $text; $dbh->disconnect(); It seems that the ->prepare() and ->execute() is necessary, it doesn't work with ->do().