<moan>
PLEASE don't use user defined functions in the select or where clauses of your queries. It makes the queries excruciatingly slow. I've spent a lot of hours the past month taking functions out of queries in storeprocs and putting the funtionality in views or subqueries. every case the performance improved from 2 minutes or 40 seconds to less than 1 second.
<subMoan>
One argument I've heard is that functions “encapsulates“ behaviour. Dude, you should be “encapsulating“ behaviour in your bussiness layer/domain model, not your database. If you have to, use a view.
</subMoan>
<subMoan>
Sql after all is a RELATIONAL database system, so why would you slap procedural constructs on top if it's not absolutely necessary?
</subMoan>
nough said
</moan>