7

Today I created a new staging table and a BCP .fmt file. I created some test data and attempted to run the BCP utility from the command line:

BCP Error

I've got about 20 different format files and staging tables from previous work and this is the first time I have encountered this error.

How can I fix this error?

Please note, I have added my solution below, but if you have other answers, please add them in. The answer was so quirky/obscure that I think it may help others.

Jon Raynor
  • 3,804
  • 6
  • 29
  • 43

1 Answers1

29

Basically, this one was really strange. In order for it to work, make sure there is an empty line after the last column defined in the format file. I added an extra empty line, resaved the file, and then the BCP utility ran the file successfully. I've indicated the extra line with a red rectangle.

BCP Fix

Jon Raynor
  • 3,804
  • 6
  • 29
  • 43
  • Oh wow. Thanks for that. You've probably just saved me hours. – Kamal Oct 23 '12 at 08:08
  • I have a problem but the opposite way. I'm exporting an XML field into a file, and the resulting file has an extra empty line at the end. – luiggig Dec 17 '13 at 23:35
  • @luiggig - You could run a post process to remove the extra whitespace at the end. Not sure if there is a BCP option to remove. – Jon Raynor Dec 18 '13 at 17:38
  • This seems to be an undocumented requirement of the format file. https://msdn.microsoft.com/en-us/library/ms191479.aspx "PWAusDevMGAM" already mentioned in the user-comments, and I've also notified the documentation-team. – Wouter Nov 30 '16 at 14:38