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.
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.
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!
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With