# BCP received a sqlstate error but task does not fail

**URL:** https://www.finalbuilder.com/forums/t/bcp-received-a-sqlstate-error-but-task-does-not-fail/4369
**Category:** Discussion
**Created:** [May 6, 2009, 10:23am UTC](https://www.finalbuilder.com/forums/t/bcp-received-a-sqlstate-error-but-task-does-not-fail/4369 "2009-05-06T10:23:20Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [May 6, 2009, 10:23am UTC](https://www.finalbuilder.com/forums/t/bcp-received-a-sqlstate-error-but-task-does-not-fail/4369/1 "2009-05-06T10:23:20Z")

</div>

I am imppporting a text file using BCP (in sql server 2k), and I put it ina run dos command action. The action is set not to ignore failures and the program exit code for success must be zero. When I run the action, it imppports a file with some garbage characters in the file. the action does not fail, it says completed, but if you look at the log iot says:

Starting copy...  
SQLState = 22001, NativeError = 0  
Error = [Microsoft][ODBC SQL Server Driver]String data, right truncation  
  
122 rows copied.  
Network packet size (bytes): 4096  
Clock Time (ms.): total&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16  
&nbsp;

how I make it translate a sqlstate=22001, nativeerror=0 from the odbc driver to an action fail in automise?

---

<div class="post-metadata">

### Author: ![paulsamways](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/p/e8c25b/32.png) [@paulsamways](https://www.finalbuilder.com/forums/u/paulsamways)
#### Post date: [May 7, 2009, 1:36am UTC](https://www.finalbuilder.com/forums/t/bcp-received-a-sqlstate-error-but-task-does-not-fail/4369/2 "2009-05-07T01:36:41Z")

</div>

Hi Juan,   
  
 If you’re using Automise 3 you can add an ‘Output Monitor’ on the action and set it to ‘Fail action if match found’ using the search string ‘SQLState = 22001, NativeError = 0’. With Automise 2 you’ll need to use the actions ‘OnStatusMessage’ to monitor the output from the action and then if the string is found set the ‘ActionResult’ & ‘Continue’ values to False in the ‘AfterAction’ script event.   
  
 Regards,   
 Paul.
