?
Solved

extract data from a table into a file

Posted on 2002-03-23
7
Medium Priority
?
537 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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
LVL 5

Accepted Solution

by:
amitpagarwal earned 400 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

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

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

This month, Experts Exchange’s free Course of the Month is focused on CompTIA IT Fundamentals.
If you're a modern-day technology professional, you may be wondering if certifications are really necessary. They are. Here's why.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

777 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