var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: BCP Error handling
I am running some bcp copies through a Sql job. I am copying 35 tables in individual steps. However, sometimes the bcp step fails to copy the data, and I want the step to fail if the data is not copied properly. Is that possible? If so, how? Any help is greatly appreciated.
Last edited by rpeoplesjr; 03-03-05 at
Are your BCP statements in a stored procedure?
Here is something I hope will help:
SET @FILENAME_C= 'c:\it.txt'
SET @SQLSTMT2='BCP "SELECT claimnumber from demo.dbo.wcclm1" queryout '+@FILENAME_C+' /c /t, /r \n /U demo /P demo /S '+@@servername
EXEC @outputcatch=MASTER.DBO.XP_CMDSHELL @SQLSTMT2, no_output --@outputcatch=OUTPUT
Note that this sample has a simple select statement. If I change claimnumber to clamnumber @outputcatch is 1 due to failure. Put it back to claimnumber and it returns 0 which indicates success.
Just keep looking at @outputcatch and if you get a 1 RETURN.