BCP Not giving Desired output.

Rakesh Dhar 96 Reputation points
2021-03-23T06:58:47.29+00:00

![80468-microsoftteams-image.png][1] [1]: /api/attachments/80468-microsoftteams-image.png?platform=QnA Hi all , Attached is the Output of a BCP Command . which is not the correct one . the marked line should be the first row .which is coming in middle of the .csv file. We are converting a .xlsx file to .csv file using rowset command and BCP command . let know what other details required..

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,000 questions
SQL Server Migration Assistant
SQL Server Migration Assistant
A Microsoft tool designed to automate database migration to SQL Server from Access, DB2, MySQL, Oracle, and SAP ASE.
538 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,656 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Erland Sommarskog 112.7K Reputation points MVP
    2021-03-23T23:01:39.033+00:00

    There is not much information in your post to work from. We don't see your tables and queries etc, so we are left to guessworks.

    However, I have an article about the bulk tools on my web site, that you may find helpful and could answer some of your questions: Using the Bulk-Load Tools in SQL Server.

    0 comments No comments

  2. CathyJi-MSFT 22,306 Reputation points Microsoft Vendor
    2021-03-24T09:37:13.177+00:00

    Hi @Rakesh Dhar ,

    > One more thing ..how can we let the BCP to generate the .csv file in UTF-8 Encoded format . right now i checked the CSV upload into table after change it into UTF-8 Manually . do we have option in BCP.

    Using below T-SQL

    bcp table_name out "drive:path\file_name" -c -C 65001  
    

    Suggest you read the blog that Erland mentioned.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.