Solved

How to set options for MS SQL 2005 via isql in linux?

Posted on 2009-04-12
2
1,186 Views
Last Modified: 2012-05-06
I regularly use MySQL, however am completely unfamiliar with MSSQL and the differences are killing me.
I have a task scheduled hourly to dump data from an Oracle database to a CSV file, which I then import into MySQL, I need now to do the same thing from a MSSQL 2005 database. All I need as results from the script are the comma separated values of the result of the query.
I need help converting the following Oracle script to be run from Debian 5.0 linux via iSQL on the command line, to be able to pull CSV data from MSSQL 2005.
SET FEEDBACK OFF
SET HEADING OFF
SET COLSEP ','
SET PAGESIZE 0
SET LINESIZE 5000
SET TERMOUT OFF
ALTER SESSION SET NLS_DATE_FORMAT='RRRR-MM-DD'
SET TRIMSPOOL ON
 
SPOOL /output/daily
SELECT FIELD1||','||
FIELD2||','||
FIELD 3 FROM TABLE WHERE CLAUSE;
SPOOL OFF
EXIT
QUIT

Open in new window

0
Comment
Question by:Madison_Hollister
2 Comments
 
LVL 37

Accepted Solution

by:
momi_sabag earned 500 total points
ID: 24128221
try this :

set nocount on
SELECT FIELD1+','+
FIELD2+','+
cast(Field3 as varchar(max))
FROM TABLE WHERE CLAUSE;

-- end of script

note - you will have to cast any non-character column as demonstrated for Field3
you will have to use linux shell to redirect the output to a file
you will need to remove the first 2 rows of the file (column headers and ----------------)
that's it (i guess, i never did it myself)

0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question