Solved

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now