Solved

extract data from a table into a file

Posted on 2002-03-23
7
508 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
  • 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SyBase SQL Syntax 7 316
installl replication server 15.7 x64 on Windows 8.1 with update 1 11 587
sql anywhere query 5 140
Default Read Only User Sybase DB 1 123
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
For months I had no idea how to 'discover' the IP address of the other end of a link (without asking someone who knows), and it drove me batty. Think about it. You can't use Cisco Discovery Protocol (CDP) because it's not implemented on the ASAs.…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

816 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now