Link to home
Start Free TrialLog in
Avatar of rss2
rss2

asked on

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

Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

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) ...
Avatar of rss2
rss2

ASKER

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

could you please show the screenshot, with the full error?
Avatar of rss2

ASKER

Screenshot attached


bcp-syntax-error.JPG
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rss2

ASKER

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
your error is now "cannot open host format file"

which means, the file w:\testformat.fmt is not accessible.
Avatar of rss2

ASKER

spot on