January 8, 2008 at 6:08 am
Hi
i want to build into a SP some way of ending the procedure if a BCP file fails to write to it's destination for whatever reason. In which case, i want it to exit the SP if it does fail and not continue to the next step. here is an example of what i am trying to do...
BEGIN
DECLARE @bcpCommand varchar(2000)
--- Create dummy file in case of network issues
SET @bcpCommand = 'bcp "select ssMainData..ssSites.Name FROM ssMainData..ssSites" queryout \\10.64.6.165\trx\dummytest2.txt -T -c -t > c:\error.txt'
EXEC Master..xp_cmdshell @bcpCommand
--if this fails, stop here and exit SP. if it works, begin next step...
begin
--- Create Kronos import file using BCP through xp_cmdshell
SET @bcpCommand = 'bcp "select ssMainData..TEMP_TABLE.CLOCK FROM ssMainData..TEMP_TABLE" queryout \\10.64.6.18\trx\111111.in -T -c -t'
EXEC Master..xp_cmdshell @bcpCommand
end
end
Any help appreciated, thanks in advance
Clive
January 10, 2008 at 11:22 am
In your procedure it would not show bcp failed because you used xp_cmdshell. It just checked if xp_cmdshell executed, then it returned a successful status.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply