Solved

importing data from a csv file into a sybase table

Posted on 2004-10-14
8
693 Views
Last Modified: 2008-02-26
Can any one give me the import statement to import data from a csv file into a sybase table ?
0
Comment
Question by:Joserip
  • 4
  • 2
8 Comments
 
LVL 24

Expert Comment

by:Joe Woodhouse
Comment Utility
Assuming carriage returns for the row delimiters:

bcp [database].[owner].[table] in [file] -U[user] -S[server] -c -t,

You could optionally add " -e [errorfile] " to produce a file where any failed rows will be logged.

You may have to enable the database option "select into" in the destination database depending on whether this table has indexes or triggers. (Enable if they do - this will be "fast bcp".)

The Utility Guide for Sybase has a good chapter on using bcp.

Joe
0
 

Author Comment

by:Joserip
Comment Utility
Thanks ! if my .csv file is in C drive how will I give this comand
0
 
LVL 24

Expert Comment

by:Joe Woodhouse
Comment Utility
The Sybase client must have been installed. You can run this from a DOS prompt or command line. You must supply the full path to the file, or be in its local directory.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:Joserip
Comment Utility
Thanks ! I am running it through a query tool conntecting to the DB . I am able to select the records in the table etc .

If I run the select commnad this way it runs well select count(*) from tablename

so I am using the bcp command this way

bcp tablename  in 'c:\test.csv'  -U user1  -S servername  -c -t

but I am getting an error near the 'in'  area
0
 
LVL 24

Accepted Solution

by:
Joe Woodhouse earned 50 total points
Comment Utility
Ah, I see a couple of problems in your command line.

#1: bcp must specify, at a minimum, the database you're loading into.
#2: You must put the comma after the "-t"... "-t" means "use this character for your column terminators", and you want to use a comma.

Your actual command line would be, including the final comma:

bcp  databasename..tablename  in  "c:\test.csv"  -Uuser  -Sserver  -c  -t,

Note the two dots between the database and table names. This is standard Sybase syntax, it is short for

database.owner.object

If the owner is the default "dbo" (database owner) then you can omit it, but you still need the dots on either side of it.

Let us know how that goes!
0
 
LVL 24

Expert Comment

by:Joe Woodhouse
Comment Utility
Hi, how did you go with that?
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Marketing can be an uncomfortable undertaking, especially if your material is technology based. Luckily, we’ve compiled some simple and (relatively) painless tips to put an end to your trepidation and start your path to success.
This article will show you how to create an ISO CD-ROM/DVD-ROM image (*.iso), and MD5 checksum signature, for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5). It's a good idea to compare checksums, because many installations fail because of a corr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 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

10 Experts available now in Live!

Get 1:1 Help Now