Link to home
Start Free TrialLog in
Avatar of vishali_vishu
vishali_vishu

asked on

pull data from sybase

I have a query in sybase (sql)  and i want to pull the data from that sql to a flat file using a shell script.

Just as we use sqlplus to pull oracle data and spool it to a file.


How to do this?
Avatar of Jan Franek
Jan Franek
Flag of Czechia image

You may use isql or bcp.

isql lets you run any query or procedure, but output will contain some clutter (names of columns, horizontal dividing lines, number of returned records etc)

bcp cen give you clear data, but you can output only tables or views (so you have to store your query as a view and then you can use bcp).

See http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.utility/html/utility/title.htm for detailed explanation of both these utilities.
I'm not as familiar with Sybase as with Oracle, but I do use dbisql just a bit, here is what I know

I have a script tables.sql to list the tables in my Sybase database

--tables.sql:
select * from sysobjects where type = 'U'

dbisql -c "UID=dba;PWD=sql" tables.sql > results.txt

Open in new window

Avatar of vishali_vishu
vishali_vishu

ASKER

is it possible to pull to pull few columns from a table (sybase table).

ex: Table_x (col_1,col_2,col_3,col_4,col_5).

can i use the bcp to pull only col_2 and col_5 ?


ASKER CERTIFIED SOLUTION
Avatar of alpmoon
alpmoon
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
By the way, if you want a quicker solution without more flexilbility, creating a view including only these columns would be easier.