If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Sybase > bcp in issue

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-10-07, 05:48
bojw bojw is offline
Registered User
 
Join Date: Jul 2007
Posts: 1
Thumbs up bcp in issue

Hi,

I need to know how to do a bcp in for the following file which have quotes on the column. Any idea how can I get the data into a table? Format below.
"P",100529,"USD"

create table t1
(
c1 char(1),
c2 int,
c3 varchar(3)
)

appreciate your help. PM me is possible.
tks.
Reply With Quote
  #2 (permalink)  
Old 07-11-07, 16:31
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
use a format file e.g.
Code:
1> create table t1 (c1 char(3), c2 int, c3 varchar(100))
2> go

$ cat t1.txt
"NY",2,"New York, USA"
"II",1,"India"
"GP",3,"Gauteng, RSA"
$ cat t1.fmt
10.0
4
1       SYBCHAR 0       100     "\""    0       junk1
2       SYBCHAR 0       100     "\","   1       data1
3       SYBCHAR 0       100     ",\""   2       id
4       SYBCHAR 0       100     "\"\n"  3       address
$ bcp tempdb..t1 in t1.txt -Usa -P -Smysrv  -f t1.fmt -e t1.err

Starting copy...

3 rows copied.
Clock Time (ms.): total = 1  Avg = 0 (3000.00 rows per sec.)

1> select * from t1
2> go
 c1  c2          c3                       
 --- ----------- -----------------------------------------------
 NY            2 New York, USA            
 II            1 India                    
 GP            3 Gauteng, RSA             

(3 rows affected)
1> drop table t1
2> go
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On