paragkalra has asked for the wisdom of the Perl Monks concerning the following question:

Hello All,

I am just curious to know if it is possible to specify database name in the DSN string of the DBI driver - DBI:ODBC

I am trying to create a table through Perl and by default it is creating in default database so wanted to change that.

Also is it possible to execute a SQL query (specific Microsoft SQL Server) through Perl DBI:ODBC that spans over 2 different SQL Server databases?

  • Comment on Specifying Database in DSN string of DBI:ODBC

Replies are listed 'Best First'.
Re: Specifying Database in DSN string of DBI:ODBC
by mje (Curate) on Jan 25, 2010 at 09:27 UTC

    It is possible. You can use 'dbi:ODBC:xxxx' and all xxxx will be passed to SQLDriverConnect and hence you can use connection strings like 'dbi:ODBC:driver={mydriver};database=mydatabase;uid=me;pwd=mypassword'. It just depends what ODBC connection attributes your ODBC driver supports. I believe MS SQL Server supports 'database' but you can also specify the database in any DSN you create via the ODBC Administrator.

Re: Specifying Database in DSN string of DBI:ODBC
by marto (Cardinal) on Jan 25, 2010 at 09:30 UTC
Re: Specifying Database in DSN string of DBI:ODBC
by paragkalra (Scribe) on Jan 25, 2010 at 10:06 UTC

    @Marto - I apologize for being so ignorant. I have went through contents of the URL you shared with me. Won't repeat it henceforth.