Solved

extract data from a table into a file

Posted on 2002-03-23
7
524 Views
Last Modified: 2006-11-17
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.
0
Comment
Question by:white_bird
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 5

Expert Comment

by:amitpagarwal
ID: 6894174
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
0
 

Author Comment

by:white_bird
ID: 6895434
I created the view.  I do not know how to use the bcp utility.  Can you help me more.
Thank you.
white-bird
0
 

Author Comment

by:white_bird
ID: 6895435
I created the view.  I do not know how to use the bcp utility.  Can you help me more.
Thank you.
white-bird
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 5

Accepted Solution

by:
amitpagarwal earned 100 total points
ID: 6895446
At the prompt say:

bcp database..CMC_GRGR_View  out flatfilename -c -U username -P password -S server

Cheers !!

usage: bcp [[database_name.]owner.]table_name[:slice_number] {in | out} datafile
        [-m maxerrors] [-f formatfile] [-e errfile]
        [-F firstrow] [-L lastrow] [-b batchsize]
        [-n] [-c] [-t field_terminator] [-r row_terminator]
        [-U username] [-P password] [-I interfaces_file] [-S server]
        [-a display_charset] [-q datafile_charset] [-z language] [-v]
        [-A packet size] [-J client character set]
        [-T text or image size] [-E] [-g id_start_value] [-N] [-X]
        [-M LabelName LabelValue] [-labeled]
        [-K keytab_file] [-R remote_server_principal]
        [-V [security_options]] [-Z security_mechanism]
0
 
LVL 5

Expert Comment

by:amitpagarwal
ID: 6895447
substitue database, server, user, password with ur specific values
0
 

Expert Comment

by:Ejaz
ID: 6939926
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

0
 

Expert Comment

by:Ejaz
ID: 6939927
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

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Facebook has became the #1 social media platform. People share many funny videos there, yet you don't know how to download them? Now you can download Videos from Facebook in just 3 simple steps.
While it may be true that the internet is a place of possibilities, it is also a hostile environment lurking with many dangers. By clicking on the wrong link, trusting the wrong person or using a weak password, you are virtually inviting hackers to …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question