Hi,
I'm trying to capture the error in the @ErrorSave variable, but without success. Please see below.
Any help would be appreciated.
Thanks in advance
TK
CREATE TABLE [dbo].[complaint1](
[Complaint_No] [varchar](8) ,
[Complaint_Description] [varchar](50)
)
/*
Data in the text file d:\complaint.txt
hhhhhhhhhhhhhhhhhhhhhhh
FUPHLD,Fully Upheld (complaint fully upheld),jhj
SPUPHLD,Significant Points of complaint upheld
MPUPHLD,Minor Points of complaint upheld
NOTUPHLD,Complaint not upheld
UNDINVES,Complaint received and under investigation
*/
declare @ErrorSave int
set @ErrorSave=0
set nocount on
BULK INSERT FOI.dbo.complaint1 FROM "d:\complaint.txt" WITH ( FIELDTERMINATOR ='\,')
IF (@@ERROR <> 0) SET @ErrorSave = @@ERROR
select @ErrorSave
select * from complaint1
drop table complaint1
--Error message
--Msg 4863, Level 16, State 1, Line 14
--Bulk load data conversion error (truncation) for row 1, column 1 (Complaint_No).
I'm trying to capture the error in the @ErrorSave variable, but without success. Please see below.
Any help would be appreciated.
Thanks in advance
TK
CREATE TABLE [dbo].[complaint1](
[Complaint_No] [varchar](8) ,
[Complaint_Description] [varchar](50)
)
/*
Data in the text file d:\complaint.txt
hhhhhhhhhhhhhhhhhhhhhhh
FUPHLD,Fully Upheld (complaint fully upheld),jhj
SPUPHLD,Significant Points of complaint upheld
MPUPHLD,Minor Points of complaint upheld
NOTUPHLD,Complaint not upheld
UNDINVES,Complaint received and under investigation
*/
declare @ErrorSave int
set @ErrorSave=0
set nocount on
BULK INSERT FOI.dbo.complaint1 FROM "d:\complaint.txt" WITH ( FIELDTERMINATOR ='\,')
IF (@@ERROR <> 0) SET @ErrorSave = @@ERROR
select @ErrorSave
select * from complaint1
drop table complaint1
--Error message
--Msg 4863, Level 16, State 1, Line 14
--Bulk load data conversion error (truncation) for row 1, column 1 (Complaint_No).