BCP format file? Syntax error?

Hi Experts,

I'm trying to create a format file from a table, to be used in the Bulk Insert Task of a step in an SSIS package I'm building.

The reason I want to use a format file is because I need to import a very large csv file every day into the database (hence the use of the Bulk Insert rather than normal Data Flow), and I notice the csv file is sometimes incomplete. Sometimes the last line of the file just ends abruptly.

While that needs to be fixed, that's not my problem. And I must pull in all the data regardless of things like that.. at least for now.

So I thought a format file would do the trick. Am I right? If not, what do you think?

On the database server itself, I run this line and get a syntax error:
bcp Diamond.dbo.STG_CUSTOMERCOMPLAINTS_BIT format nul -c -f "w:\testformat.fmt" -S cnwp0145 -T

The syntax error is attached.

I can't figure out what I'm doing wrong here. Could you help me?

Thank you,

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
let's try to see how you run the command:
from the SQL Server Query tool, or from the OS command line?
it must be the OS command line tool, as BCP is NOT a SQL or T-SQL command, but a command line tool (bcp.exe) ...
rss2Author Commented:
I ran it from the command line on the server..

bcp Diamond.dbo.STG_CUSTOMERCOMPLAINTS_BIT format nul -c -f "w:\testformat.fmt" -S cnwp0145 -T

Guy Hengel [angelIII / a3]Billing EngineerCommented:
could you please show the screenshot, with the full error?
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

rss2Author Commented:
Screenshot attached

Guy Hengel [angelIII / a3]Billing EngineerCommented:
the output shows that the version of BCP is not sql 2008.
please double-check with version of the bcp you are using, possibly one older sql installation has priority in the "PATH" ...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rss2Author Commented:
Looks like I was using the Sybase version of bcp.

Here is the result of using SQL Server 2008's bcp (screen shot attached).

Thank you for your help!!!!
Guy Hengel [angelIII / a3]Billing EngineerCommented:
your error is now "cannot open host format file"

which means, the file w:\testformat.fmt is not accessible.
rss2Author Commented:
spot on
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.