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

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.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
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 Select All

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

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)

Random Solutions  
 
programming4us programming4us