Is it possible to override an error message in a stored procedure. I have code that performs an update statement. I want the code to continue through to the next record if if fails on the previous record due to a data type error (245).
At the moment, as soon as it hits a record that has the wrong data type, it fails and displays the error halting the stored procedure.
Declare @contact_number int
Declare @title varchar(10)
Declare @forenames varchar(50)
Declare @surname varchar(90)
Declare @ID int
Declare CursorFields cursor for
SELECT contact_number, title, forenames,surname,ID
FROM Members
open CursorFields
fetch next from CursorFields
into @contact_number,@title,@forenames,@surname,@ID
while @@fetch_status = 0
begin
While @@error = 0
Begin
Exec InsertIndividuals @contact_number , @title , @forenames , @surname , @ID
End
If @@Error <> 0
Begin
...Do some code
End
fetch next from CursorFields
into @contact_number,@title,@forenames,@surname,@ID
End
close CursorFields
deallocate CursorFields
At the moment, as soon as it hits a record that has the wrong data type, it fails and displays the error halting the stored procedure.
Declare @contact_number int
Declare @title varchar(10)
Declare @forenames varchar(50)
Declare @surname varchar(90)
Declare @ID int
Declare CursorFields cursor for
SELECT contact_number, title, forenames,surname,ID
FROM Members
open CursorFields
fetch next from CursorFields
into @contact_number,@title,@forenames,@surname,@ID
while @@fetch_status = 0
begin
While @@error = 0
Begin
Exec InsertIndividuals @contact_number , @title , @forenames , @surname , @ID
End
If @@Error <> 0
Begin
...Do some code
End
fetch next from CursorFields
into @contact_number,@title,@forenames,@surname,@ID
End
close CursorFields
deallocate CursorFields