|
Posted by Metal Dave on 10/01/50 11:33
I do not understand the error handling of SQL Server here. Any error in
bulk insert seems to halt the current T-SQL statement entirely, rendering
it impossible to log an error. The first statement below executes as
expected, and were I to replace "print" with something meaningful I could
do some useful error handling. The second statement just seems to totally
bail out after the error, preventing me from doing any useful error
handling. This is a problem b/c I would like to schedule bulk inserts and
need to be notified if there is a problem.
The following can be run in QA to demonstrate:
print 'BEFORE TYPICAL ERROR'
raiserror('Some Error', 16, 10)
if (@@ERROR <> 0) print 'I can catch and log this error - good!' else
print 'I can not catch and log this error - bad!'
print 'AFTER TYPICAL ERROR'
go
print 'BEFORE BULK INSERT'
Bulk insert Northwind.dbo.orders
from 'ThisFileDoesNotExist'
if (@@ERROR <> 0) print 'I can catch and log this error - good!' else
print 'I can not catch and log this error - bad!'
print 'AFTER BULK INSERT'
go
TIA,
Dave
Navigation:
[Reply to this message]
|