Bulk Insert from csv having issues with double quotes

Sarath 106 Reputation points
2021-01-20T07:55:09.193+00:00

Hi Team,

58406-image.png

I am using Bulk Insert to load the data from CSV into SQL Table.

I have used , (comma) as a field terminator and it was working fine.

But in my csv file I have the Project Manager field which has in the format as (Lastname, Firstname)
eg: Ramasamy, Sarath. 58504-image.png

The project manager field is separated using double quotes, while doing bulk insert the fields are seperated and filled into table in tow columns

58370-image.png

Please suggest a way to fix.

Thanks - Sarath

SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,449 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,545 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Monalv-MSFT 5,891 Reputation points
    2021-01-21T07:52:06.25+00:00

    Hi @Sarath ,

    We can use Flat File Source and OLEDB Destination to load data from csv file to sql table in ssis package.

    Please set Text qualifier as " in General page of Flat File Connection Manager Editor.

    Please refer to the following pictures:
    58990-csv-file.png
    59004-df.png
    58965-ffcm-general.png
    58967-ffcm-columns.png
    58968-output.png

    Best Regards,
    Mona

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    3 people found this answer helpful.

  2. Tom Phillips 17,716 Reputation points
    2021-01-20T16:37:39.517+00:00

    BCP cannot handle double quotes sometimes and not other times. The string fields must be ALL double quoted all the time.

    The only way to import the data as shown, would be to use SSIS. In SSIS, you can specify a "text qualifier" and it is technically optional, and will import the data as expected.

    0 comments No comments

  3. Jeffrey Williams 1,886 Reputation points
    2021-01-20T19:17:45.137+00:00
    0 comments No comments