cancel
Showing results for 
Search instead for 
Did you mean: 

Sybase 10 Unload to csv, wrapping field values in DOUBLE quotes

Former Member
4,679

I have a csv file that unloads a view from our database. It works fine, but the client wants all string data wrapped in double quotes rather than the single quotes as Sybase defaults to.

Does anyone know the command to do this? Here is what I have right now:

UNLOAD
SELECT * FROM Sybase_view
TO 'c:\\\\file.csv' ENCODING 'UTF-8';

Accepted Solutions (1)

Accepted Solutions (1)

johnsmirnios
Advisor
Advisor

http://dcx.sybase.com/index.html#1201/en/dbreference/unload-statement.html*d5e64802

Add the following clause to the unload statement:

QUOTE '"'

Former Member
0 Kudos

Thanks for the help, unfortunately I get an error when I add the quote option

UNLOAD SELECT * FROM Sybase_view TO 'c:\\file.csv' ENCODING 'UTF-8'; QUOTE "";

"An error occurred while saving the code. Syntax error near '(end of line)' on line 8"

Any ideas?

johnsmirnios
Advisor
Advisor
0 Kudos

The QUOTE clause goes on the UNLOAD statement, it is not a separate statement afterwards. Remove the ';' statement separator as done below. See the doc link provided above for syntax details.

UNLOAD SELECT * FROM Sybase_view TO 'c:file.csv' ENCODING 'UTF-8' QUOTE "";

MarkCulp
Participant
0 Kudos

Remove the semicolon after 'UTF-8'! I.e. use:

UNLOAD SELECT * FROM Sybase_view TO 'c:\\file.csv' ENCODING 'UTF-8' QUOTE '"';
VolkerBarth
Contributor
0 Kudos

Just omit the semicolon before the QUOTE - the QUOTE is a clause that belongs to the UNLOAD statement, just as the ENCODING clause does. - And note, the following chars are one single quote, a double quote and another single quote (just in case that may be not so obvious...)

VolkerBarth
Contributor
0 Kudos

Wow, UNLOAD SELECT COMMENT ON is soo fast:)

That's parallel execution on several "cores" distributed across the Atlantic ocean, with distinct cache, apparently:)

Former Member
0 Kudos

Ok, I figured out my error. I literally typed out two double quotes, instead of copying what you had which is a single quote, followed by a double quote, followed by a single quote again. Thanks so much for your help!

Answers (0)