SQL SERVER 2005 BCP Format File Creation Error


I am having an issue with SQL Server 2005's BCP utility. I am running SQL Server Express 2005 on Windows Vista. I am trying to create a non-XML format file for some tables in my database.

I run the following code:

bcp 'jProd_000-1'.users format nul -T -f users.fmt 

I get the following error:

An Error occurred while processing the command line

It doesn't display any other helpful information with regards to the error. I also used a SQL Server login instead of the '-T'. Can anyone provide any insight? What am I doing wrong?

Thank you!


Your quoting looks a little odd. Is jProd_000-1 a schema?

Assuming it is, try

bcp "jProd_000-1.users" format nul -T -f users.fmt 

However, this may not do what you expect - it will ask you to define the datatypes for each column manually.

There's no way I'm aware of to automatically generate a non-XML format file.

By : Ed Harper

I just figured it out... yeah rookie mistake. It had to do with the database name I used. Aparently there's no way to use BCP on database names that contain "-"'s, even if you put the database name in double or single quotes. Thank you for the response!

I was getting the same problem with BCP against SQL 2008. Using square brackets around the database name seemed to resolve it. Worth a try. e.g:

bcp "[database-name].dbo.table" format nul -T -f users.fmt

This video can help you solving your question :)
By: admin