in reply to 'use database' for sqlserver

Try http://www.ConnectionStrings.com/ says Database=myDataBase; so you might try Database={$database}; or even  $dbh->do("use ". $dbh->quote_identifier($database) );

Replies are listed 'Best First'.
Re^2: 'use database' for sqlserver (connectionstrings)
by runrig (Abbot) on May 22, 2013 at 01:18 UTC
    I use $dbh->do("use $database"); ('$database' is sufficiently trusted in my env, YMMV). Putting the database into the connect string, at least for DBD::Sybase (I don't know about DBD::ODBC), resulted in a warning when I really wanted it to throw an error, e.g., when the server was up, but the database was not 'ready'. The do(..) method throws an error if RaiseError is set.