Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are some ways of accessing Microsoft SQL Server from Linux?

Tags:

sql-server

We have a Windows machine running SQL Server 2005, and we need to be able to run some database queries on it from a Linux box. What are some of the recommended ways of doing this? Ideally, we would want a command-line utility similar to sqlcmd on Windows.

like image 684
cwick Avatar asked Sep 29 '08 16:09

cwick


People also ask

How do I connect to Microsoft SQL Server from Linux?

Use the following steps to install the mssql-tools on SUSE Linux Enterprise Server. Add the Microsoft SQL Server repository to Zypper. Install mssql-tools with the unixODBC developer package. Optional: Add /opt/mssql-tools/bin/ to your PATH environment variable in a bash shell.

Can you run Microsoft SQL Server on Linux?

Starting with SQL Server 2017 (14. x), SQL Server runs on Linux. It's the same SQL Server database engine, with many similar features and services regardless of your operating system. SQL Server 2019 is available!

How do I access SQL Server database from another computer Linux?

To connect to the Database Engine from another computer On a second computer that contains the SQL Server client tools, log in with an account authorized to connect to SQL Server, and open Management Studio. In the Connect to Server dialog box, confirm Database Engine in the Server type box.

How do I view SQL database in Linux?

To open the connection, double-click on the icon. After obtaining your password, an SQL editor opens in a new tab and connects to the server. The example here shows a connection to the sample MySQL database. The left hand pane shows the database schema , including the tables that had been previously created.


1 Answers

FreeTDS + unixODBC or iODBC

Install first FreeTDS, then configure one of the two ODBC engines to use FreeTDS as its ODBC driver. Then use the commandline interface of the ODBC engine.

unixODBC has isql, iODBC has iodbctest

You can also use your favorite programming language (I've successfully used Perl, C, Python and Ruby to connect to MSSQL)

I'm personally using FreeTDS + iODBC:

$more /etc/freetds/freetds.conf [10.0.1.251]     host = 10.0.1.251     port = 1433     tds version = 8.0  $ more /etc/odbc.ini [ACCT] Driver = /usr/local/freetds/lib/libtdsodbc.so Description = ODBC to SQLServer via FreeTDS Trace = No Servername = 10.0.1.251 Database = accounts_ver8 
like image 66
Vinko Vrsalovic Avatar answered Oct 02 '22 04:10

Vinko Vrsalovic