for ($i=0;$i<$#databases+1;$i++) { $database = $databases[$i] ; ### Use DB $dbh->do("USE $database") || log_message ("SERI","Database error $dbh->errstr") ; ### Get details from sysobjects $sql = ""; $sql = "SELECT 1" ; $sth = $dbh->prepare($sql); $sth->execute(); ## Here it goes to master ?????? $objcount =0; while (@row = $sth->fetchrow_array) { ($object = $row[0]) =~ s/\s//g ; print "$object \n"; get_db_name(); $sql = ""; $sql = "GRANT ALL ON $object TO PUBLIC" ; # $dbh->do($sql) || log_message ("SERI","Database error $dbh->errstr"); $objcount ++; } ## end of while ## Here it again shows the correct DB log_message("INFO","$objcount objects affected in $database"); } ## end of for