I have the following code to loop through a list of names in Table1. I want to add error handling, so that if error occurs while executing usp_Storedproc1, the execution moves to the next name in the cursor without breaking the program flow.
declare lcursor cursor read_only
for select DISTINCT Name from Table1 where flag = 1 AND type='Test'
fetch next from lcursor into @Name
while @@fetch_status = 0
exec usp_Storedproc1 @Name
fetch next from lcursor into @lservername