errorlevel - How to run bcp commands one by one -
i want execute 15 "bcp commands" 1 one in 1 single batch file/script.. every command should process or execute after previous command executed.. if in case command fails execute..the script should stop execution...
i tried this..but didn't sufficient output need..
bcp.exe "select * orderxpress.dbo.customers custid < 1000" queryout "d:\customer.dat" -s localhost -u sa -p sa12345 -e -n if %errorlevel% > 0 ( pause ) bcp.exe orderxpress.dbo.customers out "d:\customer2.dat" -s localhost -u sa -p sa12345 -e -n if %errorlevel% > 0 ( pause ) bcp.exe orderxpress.dbo.orders out "d:\orders.dat" -s localhost -u sa -p sa12345 -e -n if %errorlevel% > 0 ( pause )
please try this...
begin try bcp.exe "select * orderxpress.dbo.customers custid < 1000" queryout "d:\customer.dat" -s localhost -u sa -p sa12345 -e -n
end try
begin catch
declare @msg varchar(1000) set @msg = error_message() raiserror(@msg,16,0)
end catch
Comments
Post a Comment