Skip to Content.
Sympa Menu

freetds - [freetds] Saving Query output to a local file?

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Vinh Nguyen <vinhdizzo AT gmail.com>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] Saving Query output to a local file?
  • Date: Thu, 15 Apr 2010 19:01:13 -0700

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




Archive powered by MHonArc 2.6.24.

Top of Page