0

Hello,

I'm using SQLBulkCopy to import data from a text file. There is a lot of data involved and I would really rather not import it row by row. There seems to be a problem with fields containing both numbers and text. (for example, a phone number '555-1212'). All fields that are mixed (numeric / text) are imported as null. Is there anyway to get this working?

I have no control over the format of the text file, as it is an export of data from a vendor application.

Thanks,
Rachel

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by buddylee17
0

SQLBulkCopy is only handy when the source and destination schemas match up. It sounds like you are trying to pump varchar or char into an int column.

I have no control over the format of the text file, as it is an export of data from a vendor application.

I'd recommend either

a.) write a data preprocessor that will read the file into memory, perform string functions to clean the data and make it compatible with the destination (remove the dashes from the phone number), then pump the new file out to be bulk copied.

OR

b.) learn SSIS. This is the exact reason that SSIS is so popular in the Enterprise. You can design, develop, and implement this process in a matter of minutes.

Post back if you need any help on this.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.