Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Basically I want to write all the lines of a text file present in linux machine to Microsoft SQL server database. I need a shell script to connect from my Linux machine to a remote Microsoft SQL Server (2008) database and do insertion. How do I do this?

share|improve this question
That's nice to know, but what's the question? – Marco Mar 11 '13 at 12:04
@Macro : Basically I am not getting any way to connect to sql server database from Linux.Need help for that – satyajit Mar 11 '13 at 12:21
What exactly do you want to do from the UNIX host with the SQL Server? Just running SQL commands and seeing the output or writing a whole application/software? Or monitoring it in some way? – Tonin Mar 11 '13 at 12:25
-1: It is completely unclear what you want. You want to connect to the SQL server installed on your machine, from the Unix machine that you logged in to? Or the other way around. Please be really specific, because I don't understand yet. – Bernhard Mar 11 '13 at 12:26
microsoft.com/en-us/download/details.aspx?id=28160 msdn.microsoft.com/en-us/sqlserver/aa937724.aspx ... one or both of those should help. You'll have to write a minimal amount of code (well, actually, maybe not, since you can find things that already use ODBC or JDBC) – derobert Mar 11 '13 at 14:07

AFAIK, MSSQL Server is a modified version of a SyBase RDBMS.

At least with MSSQL 2005, the SyBase tools worked for MSSQL as well. It may still be the case with MSSQL 2008.

Look for FreeTDS, a free implementation for accessing such servers.

It comes with sqsh, a command-line SQL client, and also an ODBC driver which you can then use with any ODBC aware utility or language module (like perl's DBI).

share|improve this answer

If I understand correctly, you want to import the contents of a text file on a Unix or Linux OS in a SQL Server database. The first thing that comes to mind is that Unix/Linux and Windows use different characters for newlines, so a utility like dos2unix might be useful. Second, why not just use scp to copy the file to the SQL Server machine and import? Third, you're asking for trouble IMHO.

share|improve this answer
well microsoft DB is build to run with applicative so it doesn't really care from where you are connecting. As long as you have a driver for that. in this case I almost sure SQL server use ODBC and I can prove it --> microsoft.com/en-us/download/details.aspx?id=28160 – Kiwy Dec 19 '13 at 16:05

Your Answer


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.