Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 745
  • Last Modified:

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,
rss2

0
rss2
Asked:
rss2
  • 4
  • 4
1 Solution
 
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) ...
0
 
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

0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
could you please show the screenshot, with the full error?
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
rss2Author Commented:
Screenshot attached


bcp-syntax-error.JPG
0
 
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" ...
0
 
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!!!!
bcp-syntax-error-II.JPG
0
 
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.
0
 
rss2Author Commented:
spot on
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now