Link to home
Start Free TrialLog in
Avatar of white_bird
white_bird

asked on

extract data from a table into a file

I like to extract 2 fields f1 and f2 from a Sybase table CMC_GRGR, into a fileA, then use the fileA to creat a NEW table in Oracle to contain f1 and f2.  How can I do that?

Thank you in advance.
Avatar of amitpagarwal
amitpagarwal
Flag of India image

Step 1: Create a view in Sybase as
Create view CMC_GRGR_View as
select f1, f2 from CMC_GRGR

Step 2: Extract the view into a flat file using BCP

Use bcp -h to see more option.

Cheers,
Amit
Avatar of white_bird
white_bird

ASKER

I created the view.  I do not know how to use the bcp utility.  Can you help me more.
Thank you.
white-bird
I created the view.  I do not know how to use the bcp utility.  Can you help me more.
Thank you.
white-bird
ASKER CERTIFIED SOLUTION
Avatar of amitpagarwal
amitpagarwal
Flag of India 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
substitue database, server, user, password with ur specific values
Hi,
   After creating the View, just use this following bcp command at the operating system prompt.

bcp <DB NAME>..<TBL NAME> out -U <User NAME> -P <Password> -t "|" -c -S <Server Name>


U can use any character as seprator between the value of 2 filed , just as I had used "|"

After that use the text file which is the o/p of above for SQL Loader to load the data into Oracle Database. Beofre that U will had to create a table with the same struc. in Oracle and then use SQL Loader.

If any more query let me know.

Till then
Cheers

Hi,
   After creating the View, just use this following bcp command at the operating system prompt.

bcp <DB NAME>..<TBL NAME> out<text file name> -U <User NAME> -P <Password> -t "|" -c -S <Server Name>


U can use any character as seprator between the value of 2 filed , just as I had used "|"

After that use the text file which is the o/p of above for SQL Loader to load the data into Oracle Database. Beofre that U will had to create a table with the same struc. in Oracle and then use SQL Loader.

If any more query let me know.

Till then
Cheers