Solved

BULK INSERT and bcp

Posted on 2001-06-14
7
518 Views
Last Modified: 2012-06-27
Is there any way to get BULK INSERT (or bcp) to ignore quotes enclosing character data in an comma-delimited ASCII text file?
My preferred method for this import is to use a bcp format file but I find that the quotes are always imported along with the data.
Thanks
0
Comment
Question by:sduckett
[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
  • 3
7 Comments
 
LVL 5

Expert Comment

by:amitpagarwal
ID: 6190226
i would suggest that after exporting the data (with quotes) into a flat file, you could manipulate the text file to remove the quotes or substitute them with some another character.

if u have sed, just say
cat BCPFILE | sed 's/\"//g' > NEWFILE

or open the file in vi and goto escape mode, say 1,$ s/\"//g

Else u can even create a view on that table where the data in the view is without quotes and u could actually bcp out that view.

Thanks.

0
 
LVL 3

Author Comment

by:sduckett
ID: 6190250
amitpagarwal, thanks for your comments.
I am really looking to find out if bcp can be instructed to ignore the quotes.
The file (flat text) I must import, on a regular basis, is ENORMOUS (>15Gb, containing every address in the UK) so I would like to avoid any pre or post processing.
I was wondering if there is anything clever that can be done with the bcp format file (or some other method) to manage this common file format("character data","more data",0.59,"data").
0
 
LVL 5

Expert Comment

by:amitpagarwal
ID: 6190261
oh the file is really huge...
i can't think of anything apart from post formatting using sed ..

anyway, thanks.
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 3

Author Comment

by:sduckett
ID: 6190268
No, Thank YOU
0
 
LVL 3

Author Comment

by:sduckett
ID: 6190368
I found the following example:
It is exactly what I was looking, so I have effectively answered my own question. I am posting the solution here for future reference.

amit, Does a 'B' grade sound fair?

For the data file:

"XX",20,"CC"
"TT",30,"RD"

When the second column is type integer, the remaining columns have a character data type, and the data is in quotation marks for the character data type. Use the following BCP-format file:

4.2
7
1     SYBCHAR       0       0       "\""     0      dummy1
2     SYBCHAR       0       2       "\""     1      col1
3     SYBCHAR       0       0       ","      0      dummy2
4     SYBCHAR       0       2       ","      2      col2
5     SYBCHAR       0       0       "\""     0      dummy3
6     SYBCHAR       0       2       "\""     3      col3
7     SYBCHAR       0       0       "\r\n"   0      dummy4

0
 
LVL 5

Accepted Solution

by:
amitpagarwal earned 200 total points
ID: 6190394
Thanks sduckett, the format file is a nice idea .. wish i could think that far ..

Amit.
0
 

Expert Comment

by:viperguynaz
ID: 7350467
This helped me solve a problem...but here's an easier solution...

8.0
3
1     SQLCHAR       0       2       ","      1      col1 RAW
2     SYBCHAR       0       2       ","      2      col2 RAW
3     SQLCHAR       0       0       "\r\n"   3      col3 SQL_Latin1_General_CP1_CI_AS
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

710 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