> > > > If MSSQL Server hasn't diverged too far from being a > derivative of Sybase, you would trap those messages in an > error or a message handler - but that only works in sybperl > and DBD::Sybase AFAIK. I don't know how you would get to the > those callbacks in ODBC. HTH somewhat.
Hmmm... You can do this in the more recent DBD::ODBCs. See below. > > To: > [EMAIL PROTECTED] > > "Jenda Krynicky" cc: > > <[EMAIL PROTECTED]> Subject: get > the messages, not the rows > > 11 Sep 2003 10:37 AM > > > > > > > > Is there a way to execute an SQL command and get the > messages, not the records? > > I mean, I'd like to run > DBCC CHECKDB ('databasename') > parse the output and add the result to a daily report of my > servers' health. The question is how do I get the messages. > > I'm using DBI+DBD::ODBC and MS SQL Server 2000. Buried in the DBD::ODBC t/20SqlServer.t is an example. You need to set an error handler and set odbc_async_exec. In there is the snippet that calls "dbcc TRACESTATUS(-1)" which runs during the tests (the safest thing I think I could find to run on generic tests, but I believe DBCC CHECKDB('databasename') was the reason the original patches were submitted by David L. Good and included by me... The only "clear" documentation is in the Changes file. The Changes file also points to a specific file which calls checkdb... use strict; use DBI; sub err_handler { my ($state, $msg) = @_; # Strip out all of the driver ID stuff $msg =~ s/^(\[[\w\s]*\])+//; print "===> state: $state msg: $msg\n"; return 0; } my $dbh = DBI->connect("dbi:ODBC:PERL_TEST_SQLSERVER", $ENV{DBI_USER}, $ENV{DBI_PASS}) || die "Can't connect: $DBI::errstr\n"; $dbh->{odbc_err_handler} = \&err_handler; $dbh->{odbc_async_exec} = 1; print "odbc_async_exec is: $dbh->{odbc_async_exec}\n"; my $sth; $sth = $dbh->prepare("dbcc checkdb(model)") || die $dbh->errstr; $sth->execute || die $dbh->errstr; $sth->finish; $dbh->disconnect; Regards, Jeff > > Thanks, Jenda > (And sorry if it's on line XX of the fine manual and I just > did not find it:) ===== [EMAIL PROTECTED] === > http://Jenda.Krynicky.cz ===== When it comes > to wine, women > and song, wizards are allowed to get drunk and croon as much > as they like. > -- Terry Pratchett in Sourcery > > > >