This is a batch of SQL code I’ve been using:
BEGIN TRY
begin
BULK INSERT DBXMRPAS2.dbo.[STG_drive] FROM 'Wdmyitpxmdev1xmmsbcpcsvfile20080715drive.200807151100.extracting'
WITH
( MAXERRORS =1000,
FIELDTERMINATOR = '^',
ROWTERMINATOR = '|n'
)
end
END TRY
BEGIN CATCH
SELECT 'Error Caught'
SELECT
ERROR_MESSAGE(),
ERROR_NUMBER()
END CATCH
Why would an error from this statement not be captured by the catch if the .CSV file is missing for the given directory?
Software/Hardware used:
ASKED:
July 15, 2008 6:52 PM
UPDATED:
July 16, 2008 12:10 AM
Check out my SQL Server blog “SQL Server with Mr Denny” for more SQL Server information.