For me, in SQL Server, I'm getting this error because the query I am executing is something like so:
IF <CONDITION>
<CODE HERE>
END
ELSE
BEGIN
<CODE HERE>
END
in the above query, there's a missing BEGIN
next to the IF
it should be like below:
IF <CONDITION>
BEGIN
<CODE HERE>
END
ELSE
BEGIN
<CODE HERE>
END