Bulk Insert - CSV with and without quotes

  • Deleted - re-read the question and I was wrong

    -------------------------------Posting Data Etiquette - Jeff Moden [/url]Smart way to ask a question
    There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
    I would never join a club that would allow me as a member - Groucho Marx

  • You will need to use BCP with a format file. That way you can specify which columns are quoted and which are not. The format file has a way to specify each column, including separate delimiters which is the case when you have quoted columns.

    edit: actually I may have misunderstood you dilemma also. If some columns have quotes and others don't, I would suggest reformatting the file to strip the quotes and replace the column delimiter with something else ( like pipe or any other character that would not show up in any of the columns). I have done this in the past and it works well. It does require to write a simple reformatting utility in .NET or some other scripting language but that's pretty simple.

    The probability of survival is inversely proportional to the angle of arrival.

  • Thanks for the replies, I'll have a look into reformatting the file with .net

  • Yuck.

    You can also import each entire line into a table then use some kind of multi-pass replace() construct or a REGEX via CLR to change out the delimiters.

    ____________
    Just my $0.02 from over here in the cheap seats of the peanut gallery - please adjust for inflation and/or your local currency.

Viewing 4 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply