Hi,
Am doing Bulk insert, using while loop. but i want to collect all records which are giving error due to columns datatype mismatch with data which is inserting....for eg writing some code
in below: problem here is when am inserting string value in datetime column at 6 record, it stop executing while loop there itself. but i want to continue while loop even though error ocurs and i want insert all error givng records in some @temp table. pls help me.
declare @a int
set @a=1
DECLARE @temp TABLE(a varchar(2))
BEGIN TRY
WHILE (@a<8)
begin
INSERT INTO Temp4(DateColumn) select dtCreatedDate from Temp3 where strErrorMessage=@a
print 1
set @a=@a+1
-- delete from dbo.Temp4
end
END TRY
BEGIN CATCH
insert into @temp(a) select @a
END CATCH
select * from @temp