Search code examples
sqlsyntaxbcp

BCP failing due to NULL


I am trying to BCP a txt file to Azure.
The problem is when I have a null value, it writes the word NULL to the txt file.

How do I get around this as it causes errors when I try to BCP because it is trying to write NULL to numeric and GUID fields.


Solution

  • You have to convert the base text file to remove the NULLS.

    ISNULL(CAST(NullField AS VARCHAR(50)), '') AS NullField

    This is a huge pain in the butt in tables with a lot of columns, so if there is an easier way, by all means share.