Recently I got the task, to implement unixODBC/freetds on one (well, it’s really three) of our web servers, as someone wanted to use Microsoft SQL Server 2005 with PHP (without using the MSSQL functions, which PHP provides soo nicely; don’t ask me why).
With that I also got a set of “instructions” on how to install freetds from source (remember, I was a Gentoo dev, so I know my way around, when it comes to building from source), as well as a small set of instructions on how to create the connection.
Well, after trying to figure out why the hell the connection ain’t working with unixODBC’s tsql and PHP’s odbc functions, and yet the plain connection using telnet works … *shrug* turns out it was a simple mistake …
The “howto” said something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
; html-script: false ][FreeTDS] Description = FreeTDS unixODBC Driver Driver = /usr/lib64/libtdsodbc.so Setup = /usr/lib64/libtdsodbc.so [ODBC Data Sources] mssql = Microsoft SQL Server 2005 [mssql] Driver = /usr/lib64/libtdsodbc.so Description = MSSQLServer Trace = No Database = Database TraceFile = /var/log/freetdssql-foobar.log Servername = sql.foobar.org Port = 2433 TDS_Version = 8.0 [Default] Driver = /usr/lib64/libtdsodbc.so |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
; html-script: false ][FreeTDS] Description = FreeTDS unixODBC Driver Driver = /usr/lib64/libtdsodbc.so Setup = /usr/lib64/libtdsodbc.so [ODBC Data Sources] mssql = Microsoft SQL Server 2005 [mssql] Driver = /usr/lib64/libtdsodbc.so Description = MSSQLServer Trace = No Database = Database TraceFile = /var/log/freetdssql-foobar.log Server = sql.foobar.org Port = 2433 TDS_Version = 8.0 [Default] Driver = /usr/lib64/libtdsodbc.so |
See the difference ? If not, I’ll show you a diff:
1 2 3 4 5 6 7 8 9 10 |
; html-script: false ]--- odbc.ini.orig +++ odbc.ini @@ -12,7 +12,7 @@ Trace = No Database = Database TraceFile = /var/log/freetdssql-foobar.log -Servername = sql.barfoo.org +Server = sql.barfoo.org Port = 2433 TDS_Version = 8.0 |
Something as simple as adding another part of a word (as in “name“) to Server, makes the whole thing go wonko. Well, it ain’t going wonko per se, as Servername is different from the meaning of Server, at least when it comes to freetds.
Servername is the SQL-Server Instance name, while Server is the DNS name .. figures.