0

I'm trying to connect to SQL Server database from my Mac. Here's how I configured my drivers:

--- /etc/freetds/freetds.conf ---
[TS]
host = MISSDBServer01.xxxxxxxx.com
port = 1433
tds version = 7.0
client charset = UTF-8

--- /etc/odbcinst.ini ---
[FreeTDS]
Description = FreeTDS
Driver = /usr/local/lib/libtdsodbc.so

--- /etc/odbc.ini ---
[TS]
Driver = FreeTDS
Server = db.ip.add.ress
ServerName = xxxxAB288
Port = 1433
TDS_Version = 7.0

Everything is fine when I try to connect through tsql:

tsql -S TS -U user -P pass
locale is "en_GB.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1> select @@version
2> go

Microsoft SQL Server 2012 (SP3) (KB3072779) - 11.0.6020.0 (X64) 
    Oct 20 2015 15:36:27 
    Copyright (c) Microsoft Corporation
    Enterprise Edition: Core-based Licensing (64-bit) on Windows NT 6.2 <X64> (Build 9200: ) (Hypervisor)

(1 row affected)
1> exit

But when I tried to connect using isql, I get this error:

isql -v TS user pass
[IM002][unixODBC][Driver Manager]Data source name not found, and no default driver specified
[ISQL]ERROR: Could not SQLConnect

I followed suggestions listed here and here, and as my end goal is to connect to MS SQL Server through R, also tried solutions from here and here.

UPDATE

  1. following @Jim 's suggestion I ran odbcinst -j to get the config files directories:

    unixODBC 2.3.4
    DRIVERS............: /etc/odbcinst.ini
    SYSTEM DATA SOURCES: /etc/odbc.ini
    FILE DATA SOURCES..: /etc/ODBCDataSources
    USER DATA SOURCES..: /Users/USERNAME/.odbc.ini
    SQLULEN Size.......: 8
    SQLLEN Size........: 8
    SQLSETPOSIROW Size.: 8
    

    But when I go to /etc folder I can't find them there.. why?

  2. When I run odbcinst -q -d I get odbcinst: SQLGetPrivateProfileString failed with Unable to find component name.. I tried to fix it by creating and editing .bash_profile file, as suggested here, but it made no difference.

  3. When I run odbcinst -q -s I get odbcinst: SQLGetPrivateProfileString failed with . but at this point I'm really not sure what to do about it...

I'll appreciate any suggestions how to make it work! thanks!

Kasia Kulma
  • 1,683
  • 1
  • 14
  • 39
  • is TS your server name or DSN? I suspect you have not create any DSN for your server – sepupic Nov 02 '17 at 09:37
  • Use `odbcinst -j` to verify you are modifying the correct configuration files, `odbcinst -q -d` to list the defined drivers and `odbcinst -q -s` to list the defined data sources. – Jim Nov 03 '17 at 13:43
  • thanks, @Jim, when I run `odbcinst -j` I get `/etc/` location for the config files, but when i open this folder I can't see those files there...?? Also, when running `odbcinst -q -d` I get `odbcinst: SQLGetPrivateProfileString failed with Unable to find component name.` and when I run `odbcinst -q -s` then `odbcinst: SQLGetPrivateProfileString failed with .`. I'll try to fix the latter two with SO, but do you know the solution to the first problem? Thanks – Kasia Kulma Nov 06 '17 at 09:37
  • The system config files are optional, they don't have to actually exist. You will either need to copy the above configuration settings in your original question to the system config files or create a file in `/Users/USERNAME/.odbcinst.ini` and put the driver information there. http://www.unixodbc.org/odbcinst.html has some more information on using odbcinst and setting up your config files without a GUI. – Jim Nov 07 '17 at 12:56

0 Answers0