我有.csv
档案&已成功完成Bulk Insert
,但在插入某些值之间,其他值显示错误。是否可以从该批量插入命令捕获整个错误消息并将它们插入到ErrorLogs表中以进行跟踪?
这是我到目前为止所做的(但没有任何内容插入到我的ErrorLogs表中):
BEGIN TRY
BULK INSERT Test5
FROM 'E:\20151214.csv'
WITH
(
--MAXERRORS = 0,
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n',
DATAFILETYPE='widechar'
);
END TRY
BEGIN CATCH
INSERT INTO ErrorLogs(ErrorDate,ErrorMessage,ErrorNumber,ErrorState,ErrorLine) SELECT
GetDate() as DateTimeStamp,
ERROR_MESSAGE() as ErrorMessage,
ERROR_NUMBER() AS ErrorNumber,
ERROR_STATE() as ErrorState,
ERROR_LINE() as ErrorLine;
END CATCH
GO
那么如何将Log Errors插入到我的表中?