0

I have a SQL Server database named pm-eng that I need to connect to from a linux box. I've setup unixODBC and configured my odbc.ini as follows:

[pm_production]
Driver    = FreeTDS
Server    = mssql.server
Database  = pm-eng

When I test with iSQL, I get an error connecting saying that the the 'pm' database does not exist. I've tried wrapping the database name in [] and quotes with no luck. Ideally I would just change the name of the DB but that is not possible in this environment. I've verified my connection with a DB name that is not hyphenated and it works fine. Is it possible to connect to ODBC DSNs with hyphenated DB names?

  • Well this sounds like a really ugly workaround, but you could either (a) try a different, more flexible provider or (b) set your DSN to connect to `tempdb` and then change to `pm-eng` in your code. – Aaron Bertrand Dec 17 '12 at 15:56

2 Answers2

0

Since you're connecting to a MSSQL database maybe you can try this:

[pm_production]
Driver = FreeTDS
Server = mssql.server

And then connect with a user who's default Database is pm-eng

According to documentation found on MSDN: "If Database is not specified, the default database defined for the login is used."

Benny Hill
  • 6,191
  • 4
  • 39
  • 59
0

This turned out to be an issue with FreeTDS, not unixODBC. I needed to specify a TDS_Version in the odbc.ini file and it started working. Final config looks like this:

[pm_production]
Driver    = FreeTDS
Server    = mssql.server
Database  = pm-eng
TDS_Version = 8.0