Saving Query output to a local file?

Vinh Nguyen <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
Dear List,

First, I apologize if this question has been addressed before.  I
googled but could not find much help.

I am using FreeTDS on my Mac OS X to connect to a remote MS SQL
Server.  To get my query results, I use the following command to get
my query results to a file:
tsql -S myserverinlist -U myusername -P mypassword < query.sql > query.out

However, this captures all stuff from stdout, so the file is
contaminated with stuff like:
locale is "en_US.utf-8"
locale charset is "utf-8"
locale is "en_US.utf-8"
locale charset is "utf-8"
1> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> 17> 18> 19> 20>
21> 22> 23> 24> 25> 26> 27> 28> 29> 30> 31> 32> 33> 34> 35> 36> 37>
38> 39> 40> 41> 42> 43> 44> 45> 46> 47> 48> 49>

I'm not exactly sure if freebcp can output the raw results with
heading or not, but I tried
freebcp temp.sql queryout hello.out -S myserver -U username -P mypassword -n

but I get the following error:
Msg 102, Level 15, State 1
Server 'SPINAL', Line 1
        Incorrect syntax near 'temp'.
Msg 102, Level 15
General SQL Server error: Check messages from the SQL Server

dbsqlexec failed

Is there any easy way to obtain the query output in a file?

I tried going the unixodbc route (isql), but I failed to connect to the
server (still don' know why).  Any suggestion is greatly appreciated.

Vinh
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.