I’m decoding a very complex stored procedure and part of that is matching up BEGIN END pairs.
I have them all matched up except for one problem . . . I have one extra END hanging out there at the end of the stored procedure. . . like this:
CLOSE cursorSelect
DEALLOCATE cursorSelect
/* Select into the record set */
select *
from ##tempTable2
order by selection
drop table ##tempTable1
drop table ##tempTable2
commit transaction
RETURN
END --this is the END that seems to have no corresponding `BEGIN`
I have counted and there are 62 BEGINs and 63 END‘s. The crazy thing is if I remove the last END, the SP no longer compiles. Is there some other command that requires an END to terminate it besides BEGIN?
What’s going on here?
Off the top of my head I would guess you have a
CASEstatement, which terminates with anEND.Can you check for that, or post the entire query?