Solved

importing data from a csv file into a sybase table

Posted on 2004-10-14
8
876 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
ID: 12307320
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
ID: 12308578
Thanks ! if my .csv file is in C drive how will I give this comand
0
 
LVL 24

Expert Comment

by:Joe Woodhouse
ID: 12313362
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 Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:Joserip
ID: 12317317
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
ID: 12319368
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
ID: 12520749
Hi, how did you go with that?
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

No single Antivirus application (despite claims by manufacturers) will catch or protect you from all Virus / Malware or Spyware threats. That doesn't stop you from further protecting yourself however - and this article is to show you how.
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

679 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