Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5956397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:15:05+00:00 2026-05-22T18:15:05+00:00

As part of sql server 2005, there is the bulk copy command bcp.exe (

  • 0

As part of sql server 2005, there is the bulk copy command “bcp.exe” (http://msdn.microsoft.com/en-us/library/ms162802%28SQL.90%29.aspx)

We are running the bcp command from our msbuild script using the exec task. Unfortunately, when bcp fails to load a row of data, the build still succeeds.

I tried (per build script snippet below) specifying an error file, and checking for its existence, unfortunately that means the build always fails even if bcp completely succeeds, because it appears that bcp will always create the error file even if there are no errors.

<ItemGroup>
  <bcpFiles Include="$(DataPath)\*.txt" />
</ItemGroup>
<Delete Files="BcpErrors.txt" />
<Message Text="bcp $(DatabaseName).dbo.%(bcpFiles.FileName) in %(bcpFiles.FullPath) -eBcpErrors.txt -c -E -q -t&quot;`&quot; -r&quot;`\n&quot; $(bcpConnectionString)" />
<Exec Command="bcp $(DatabaseName).dbo.%(bcpFiles.FileName) in %(bcpFiles.FullPath) -eBcpErrors.txt -c -E -q -t&quot;`&quot; -r&quot;`\n&quot; $(bcpConnectionString)" />
<Error Condition="Exists('BcpErrors.txt')" Text="One or more bcp commands contained errors." />

Is there any way I can get msbuild to fail the build if bcp fails to load any of the data?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:15:05+00:00Added an answer on May 22, 2026 at 6:15 pm

    Ok, so it’s not exactly using bcp.exe, but BULK INSERT is very similar to bcp.exe, can take the same format of files, and has most of the same options. The Sql.Execute task will also fail if the BulkInsert query fails. So I ended up with

    <ItemGroup>
      <bcpFiles Include="$(DataPath)\*.txt" />
    </ItemGroup>
    <Sql.Execute ConnectionString="$(ConnectionString)" Sql="BULK INSERT [$(DatabaseName)].dbo.[%(bcpFiles.FileName)] FROM '%(bcpFiles.FullPath)' WITH (DATAFILETYPE='char', KEEPIDENTITY, FIELDTERMINATOR='`', ROWTERMINATOR='`\n', MAXERRORS=1)" />
    

    (Sql.Execute task is defined in Microsoft.Sdc.Common.tasks)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Part 1: In a Microsoft SQL Server 2005 failover scenario, how can the databases
i install visual-studio 2008, part ot the installation is the sql server 2005 express.
Is SQL Studio part of SQL Server 2005 Express edition? If not, how do
I am working with Microsoft SQL Server 2005, and when I execute this query:
Using Sql Server 2005. I have a long running update that may take about
Edit: using SQL Server 2005. I have a query that has to check whether
We have a database (SQL Server 2005) which we would like to get under
I'm using SSIS on SQL Server 2005 and have run across an error. As
I have a sql server 2005 table which has xml store in a text
We are using SQL Server 2005 at work and when development started it was

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.