I have code like this
to run the DBCC CHECKDB and capture the messages. It works perfect. I'd like to do the same thing for a stored procedure (some daily database maintenance task) that prints some headings and the counts of rows affected when run via the Query Analyzer, but can't seem to be able to do so. If I replace the "dbcc CHECKDB ('$database')" by "EXEC dbo.dbAdm_Daily" I getsub DBCC { my $database = shift(); my $text = ''; my $dbh = DBI->connect('dbi:ODBC:jobodbc2', 'xxxx', 'xxxx', {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; } }); my $sth = $dbh->prepare("dbcc CHECKDB ('$database')"); $sth->execute; $dbh->disconnect(); return $text; }
DBD::ODBC::st execute failed: (DBD: dbd_describe/SQLNumResultCols err= +-1)
The procedure works when started from QueryAnalyzer and prints the messages. It works as well if called with $dbh->do(), but the messages are not captured in this case. What am I doing wrong?
In reply to DBI+MS SQL, capture prints from stored procedures by Jenda
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |