Search code examples
unixsqlcmd

Is there a SQLCMD equivalent on *nix?


We have a heterogeneous environment where some developers are using OSX and some are using Windows. Our build process involves DB revision control and needs to call SQLCMD to execute arbitrary scripts - our databases are all SQL Server.

SQLCMD is the command line interface to SQL Server on Windows, similar to Oracle's SQL*Plus. The particular functionality we need is the ability to run SQL scripts from the command line. Is there a SQLCMD equivalent for *nix?

If there isn't then the only cross-platform approach I can think of would be to load a script file into memory, then execute the script.

Is there a clear leader for a library/language combination that will handle all T-SQL DDL statements? (I ask about DDL statements because they have been the hangup on this approach when I've tried it in the past.)


Solution

  • You might try the fisql utility, which is part of FreeTDS, an open-source implementation of the SQL Server wire protocol. fisql is purported to be a clone of the ancient isql, predecessor of osql, predecessor of sqlcmd, but presumably it will work with any level of T-SQL.

    Disclaimer: I haven't used FreeTDS myself.