Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

This simple command fails in bash:

echo "print 'tsql'" | sqlcmd -E

it works correctly in a regular old command prompt.

It used to work with previous versions of cygwin. I've also tried inserting various flavors of unix2dos in there, and I've looked at the output with "od -c". So I'm quite sure it's not just a LF vs. CR/LF problem.

Looking at this thread: http://cygwin.com/ml/cygwin/2010-01/msg00205.html

leads me to believe something got broken in cygwin, but I've been unable to chase down any more leads.

Does anyone have any clues, other than generating a temp file, and then using

sqlcmd -E -i tempfile

which does work, but it's ugly.

share|improve this question
try swapping quotes: echo 'print "tsql"' | sqlcmd -E –  jftuga May 9 '11 at 15:11
1) it's not a quoting problem, 2) your solution isn't valid TSQL, even if it was a quoting problem –  Eric H. May 9 '11 at 18:18

1 Answer 1

I had similar problems working with SQLCMD in Bash and as of now this question is ranked third when searching for sqlcmd cygwin on Google. I too thought that it was due to line endings because of the error,

Sqlcmd: Error: Internal error at ReadTextLine (Reason: Unspecified error).

I tried various trickery such as process substitution but that didn't work. The best that I could come up with was using

sqlcmd -Q "print 'tsql'"
share|improve this answer

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.