SQL Statemenst are rather finicky with regards to the use of quotes. I always put a SQL statement into a variable before feeding it into the UDF.
_________________________
There are two types of vessels, submarines and targets.