question

RakeshDhar-0664 avatar image
0 Votes"
RakeshDhar-0664 asked Cathyji-msft edited

BCP Not giving Desired output.

![80468-microsoftteams-image.png][1] [1]: /answers/storage/attachments/80468-microsoftteams-image.png 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-generalsql-server-transact-sqlsql-server-migration-assistant
· 7
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


If you have a SELECT and UNION statement, then show some details, because the problem can be probably solved by adding an ORDER BY.



0 Votes 0 ·

the marked line is the data row .. which is supposed to be the first row in the converted .csv file .
sure ...i will try to put the order by .and will check.

0 Votes 0 ·

If you do not use ORDER BY, there is no order. If you need it output in a specific order, you must use ORDER BY.

0 Votes 0 ·
Show more comments
    -c -t , - T  -S 

these are the parameters what we are using

0 Votes 0 ·

Hi @RakeshDhar-0664,

Any update for this thread? Just checking in to see if the answer(s) helped. If an answer is helpful, please "Accept answer" or "Up-Vote" for the same which might be beneficial to other community members reading this thread.

And If you have further questions or issues please let us know.

0 Votes 0 ·
ErlandSommarskog avatar image
0 Votes"
ErlandSommarskog answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Cathyji-msft avatar image
0 Votes"
Cathyji-msft answered

Hi @RakeshDhar-0664,

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.