Solved

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

Posted on 2009-04-12
2
1,184 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

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DTS Connection Failed 7 66
SonarQube on Linux vs Windows 3 26
Oracle Query - Return results based on minimum value 8 29
Tsql query 6 19
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Fine Tune your automatic Updates for Ubuntu / Debian
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

805 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