FreeTDS is the open source implementation of the TDS protocol described briefly in the previous paragraph.
Often you must provide a query result in CSV or other text format for integration with other systems or simply to import the data to an Excel spreadsheet for pivot tables.
Obviously you can do this using the tools offered by SQL Server, but must have administrative rights.
In this short article I would like to illustrate how to run a query on SQL Server and send the results via email. I assume that on your Unix / Linux Box is up and running FreeTDS software, freely downloadable from the site http://www.freetds.org/.
Thanks to the simplicity of the Unix / Linux, you can compose complex commands from the composition of simpler commands. The command shown below, run the query contained within the sql file and then send an email with attached the query result.
Tsql command (which is part of FreeTDS) sends the query to the SQL server specified by option-H, the result of the query is stored on the file. The output file is compressed by the command gz and finally sent as an attachment by email using the mail command. The command shown above could be useful in case you need to send data (text format) from your database application weekly or daily. Here is a simple shell script that could be put into crontab.