Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Does anyone know of a ready made1 command line tool that would allow me to connect from a linux client to a sql-server?

I want to be able to run arbitrary queries, but most of the time I want to be able to take a database dump and then restore it.

This has to be scriptable as it will integrate in an automated build environment.

1FYI: My only other alternative is to write something. I'll probably use perl and DBI

share|improve this question
add comment

3 Answers

You might want to look at SQL Workbench/J

It's Java/JDBC based thus runs fine on Linux

It supports a GUI mode, interactive commandline usage (no GUI) and can be run in batch mode. It also supports exporting into various formats in order to take the "dump".

share|improve this answer
add comment

Microsoft make a SQL Server ODBC driver for Linux, although it's binary only and only runs on certain 64 bit RHEL builds.1 Anything that can consumbe ODBC (through the unixODBC driver suite) can use it. For scripting, you could use python, perl, or anything that plays with unixODBC to automate tasks.

The package also comes with versions of bcp and sqlcmd. Sqlcmd will support interactive querying or allow queries to be embedded in shell scripts.

  1. Although you can bring it up on other builds by installing the relevant libraries - a process well known to people bringing Oracle up on Linux.
share|improve this answer
add comment
up vote 1 down vote accepted

I found tsql and while its main purpose may lie elsewhere it covers my needs.

It is included in the EPEL package. I installed it with this:
rpm -Uvh http://ftp.df.lth.se/pub/fedora-epel/6/x86_64/epel-release-6-7.noarch.rpm

FreeTDS(May 14, 2011)                                    FreeTDS(May 14, 2011)

NAME
       tsql - utility to test FreeTDS connections and queries

SYNOPSIS
       tsql   { -S servername [-I interface] | -H hostname -p port }
              -U username [-P password] [-o options]

       tsql   -C

DESCRIPTION
       tsql  is  a diagnostic tool provided as part of FreeTDS. It uses the TDS protocol directly to con-
       nect to Sybase or Microsoft SQL Servers, and allows the user to issue queries that test the  capa-
       bilities of FreeTDS.

       tsql  is  *not* a replacement for a complete isql, such as sqsh (www.sqsh.org).  It is designed to
       rely on the lowest level FreeTDS library, tdslib, as a way to isolate potential bugs in the proto-
       col implementation.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.