Search code examples
azurebcp

bcp in Microsoft Azure


I have a local .csv file that has the following content:

enter image description here

This file is located at C:\Desktop\name_table.csv on my pc.

Then I want to use bcp to upload the content in this .csv file to Microsoft Azure SQL database. I created a table called test in my Azure SQL database, and it has two columns, "name" and "ID". Then I used the following command in the Azure built-in console:

bcp mydatabase.dbo.test in C:\Desktop\name_table.csv -S ****.database.windows.net -U **** -P **** -q -c -t

I got the following result:

enter image description here

It says "0 rows copied", but there are 4 rows in my .csv file. What did I do wrong?

Thanks


Solution

  • There are a couple of things that might be of interest here:

    • Make sure the CSV uses the expected delimiter
    • Check to see if the column data types are correct
    • Make sure the csv file uses the ASCII or UTF-16 encoding since bcp does not support UTF-8.

    More information: Load data from CSV into Azure SQL Database or SQL Managed Instance (flat files)