that looks more like an error from running the script on the wrong database.
if the original SQL you pasted was valid, the rest should be valid too...
what you pasted is not the same as the original...what you pasted does not have a FROM statement...so it would fail.
the forum seems to chop some stuff out due to HTML that you want as part of your email.
the attached file passes syntax, so if the table and column objects are there, you should be good to go.
Lowell