How to connect Ubuntu to a MS SQL server 2005?

8,464

You don't have to use Wine for this purpose. Connecting Ubuntu to a Microsoft SQL server is not really possible as the Microsoft MDAC doesn't install on Ubuntu, even in Wine. Here is a good guide that I found in this sense: http://www.omegaprojex.com/index.php/2010/10/15/connecting-ubuntu-to-sql-server-2005-natively/

Here is a quick overview:

  1. Install all the packages needed to get connected to SQL server:

    sudo apt-get install iodbc libiodbc2 libct3 tdsodbc unixodbc
    
  2. Edit /etc/odbcinst.ini file and add the following:

    [FreeTDS]
    Description = FreeTDS Driver
    Driver = /usr/lib/odbc/libtdsodbc.so
    Setup = /usr/lib/odbc/libtdsS.so
    FileUsage = 1
    CPTimeout = 5
    CPReuse = 5
    
  3. Edit /etc/odbc.ini file and add the following:

    [ODBC Data Sources]
    MyServerDSN = FreeTDS Connection Server
    [MyServerDSN]
    Driver = FreeTDS
    Description = FreeTDS Connection Server
    Servername = MyServer
    Database = MyDatabase
    
  4. Edit /etc/odbc.ini file and add the following at the end of file:

    [MyServer]
    host = x.x.x.x
    port = 1433
    tds version = 8.5
    
  5. Connect to SQL server:

    isql -v MyServerDSN MyUserName MyPass
    
Share:
8,464

Related videos on Youtube

jagadeesh
Author by

jagadeesh

Updated on September 18, 2022

Comments

  • jagadeesh
    jagadeesh over 1 year

    I am using Ubuntu 13.04 and I installed Wine 1.6. I am running a dotnet application through Wine, but I am getting the following error message:

    An error occurred while establishing connection to the server. When connecting to SQL server 2005,this failure may be caused by the fact that under the default setting SQL server does not allow remote connections.

    The dotnet framework 2.0 installed in Ubuntu client. But the same dotnet applications runs in Windows client machines (Windows 7/Windows XP).

    Do I need to establish connections manually to that server? Or do I need to install any application for this to establish connections?

  • jagadeesh
    jagadeesh over 10 years
    it shows the following error message when i tried this command :$ administrator@SRMCUBUNTU:~$ sudo apt-get install iodbc libiodbc2 libct3 tdsodbc unixodbc [sudo] password for administrator: Reading package lists... Done Building dependency tree Reading state information... Done Package libct3 is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source However the following packages replace it: freetds-common E: Package 'libct3' has no installation candidate
  • jagadeesh
    jagadeesh over 10 years
    and also after entering this command : administrator@SRMCUBUNTU:~$ /etc/odbcinst.ini bash: /etc/odbcinst.ini: Permission denied what shall i do please help me
  • Radu Rădeanu
    Radu Rădeanu over 10 years
    @jagadeesh To edit those files use for example: sudo gedit /etc/odbcinst.ini. You will never edit a file from terminal only inserting its name.
  • jagadeesh
    jagadeesh over 10 years
    i did everything but still it is not working . myserver should be my server name ? and wat abt host ? please help ....and in windows i dont need to assign ip address username password nothing ......