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

Could you show the code that reads the text file and the WriteToServer command you are using?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.