As far as I know it is not possible to get bcp to output data in
comma seperated variable length (CSV) format. Is this correct?
If it is, are there any utilities which do allow you to bulk extract info
out of a Sybase table in CSV format? Preferably freeware one!
Any advice / pointers would be appreciated, thanks!
Tom.
Not entirely correct.
By specifying the bcp options '-c -t,' you get something that looks very
much like a CSV file, with all column values separated by commas. You may
need to manually remove the trailing comm (easily done with sed or awk).
CSV can actually go a bit further, and quotes a value if it contains a comma
itself. Using '-c -t\",\" ' gets quite close. You'd need to put in a leading
quote manually (again, use sed or awk).
Rob
-------------------------------------------------------------
Rob Verschoor
Certified Sybase Professional DBA for ASE 12.5/12.0/11.5/11.0
and Replication Server 12.5
Author of Sybase books (order online at www.sypron.nl/shop):
"Tips, Tricks & Recipes for Sybase ASE"
"The Complete Sybase Replication Server Quick Reference Guide"
"The Complete Sybase ASE Quick Reference Guide"
mailto:r...@YOUR.SPAM.sypron.nl.NOT.FOR.ME
http://www.sypron.nl
Sypron B.V., P.O.Box 10695, 2501HR Den Haag, The Netherlands
-------------------------------------------------------------
create view xauthors as
select constant = null
, au_id
,au_lname
,au_fname
,phone
,address
,city
,state
,country
,postalcode
from authors
Create your fmt file as
10.0
10
1 SYBCHAR 0 3 "\"" 1 constant
2 SYBCHAR 0 11 "\",\"" 2 au_id
3 SYBCHAR 0 40 "\",\"" 3 au_lname
4 SYBCHAR 0 20 "\",\"" 4 au_fname
5 SYBCHAR 0 12 "\",\"" 5 phone
6 SYBCHAR 1 40 "\",\"" 6 address
7 SYBCHAR 1 20 "\",\"" 7 city
8 SYBCHAR 1 2 "\",\"" 8 state
9 SYBCHAR 1 12 "\",\"" 9 country
10 SYBCHAR 1 10 "\"\n\r" 10 postalcode
Then run a standard bcp out.
bcp pubs2..xauthors out xauthors.dat -f xauthors.fmt -U xxxx - Pxxxx
"Rob Verschoor" <r...@DO.NOT.SPAM.sypron.nl.REMOVE.THIS.DECOY> wrote in
message news:T4KRc.58564$i7.1...@amsnews05.chello.com...
dexter:master 13.1> set rowcount 10
dexter:master 13.2> go
dexter:master 14.1> :set headers off
dexter:master 14.1> :set rowcount off
dexter:master 14.1> :printf %s,%s,"%s"
dexter:master 14.1> select id, uid, name from sysobjects
dexter:master 14.2> go
1,1,"sysobjects"
2,1,"sysindexes"
3,1,"syscolumns"
4,1,"systypes"
5,1,"sysprocedures"
6,1,"syscomments"
7,1,"syssegments"
8,1,"syslogs"
9,1,"sysprotects"
10,1,"sysusers"