(slightly off topic)
yes Begin is missing after as
You're the second one to post this. I too noticed the END at the end of the script but no BEGIN at the start of the procedure. But I would argue the opposite. The procedure is not missing the BEGIN. I would remove the END!.
I realize this is up for debate, but I strongly discourage the use of BEGIN...END around the body of stored procedures. Why? Because the END is misleading. It does not end the stored procedure. It just encloses a series of T-SQL statements. BEGIN...END is used for control flow such as IF...ELSE or WHILE. See BEGIN...END in BOL.
Don't believe me? Try executing the following script in its entirety (don't selectively execute parts).
-- Create a test procedure
CREATE PROCEDURE #TestBeginEnd(@n int)
SELECT @n AS Input;
-- Now execute it once
EXECUTE #TestBeginEnd @n = 1;
-- Now execute it a second time
EXECUTE #TestBeginEnd @n = 2;
Did you see what happened? The body of the procedure includes everything in the batch (up to the GO statement). It doesn't end with the END, so the first EXECUTE statement is part of the procedure, making it a recursive procedure. How to correct this if that was not the developer or DBA's intent? Add GO before the first EXECUTE statement. Since the GO is important and the BEGIN...END have no effect on the scope of the stored procedure body I recommend against their use in this context.
If you feel you must, you can drop the procedure afterwards. But since I demonstrated this using a temporary stored procedure you don't to do so (it will be dropped automatically when you close the connection).
DROP PROCEDURE #TestBeginEnd;