Hi Guys,
Couldn't help dipping my toe in these waters.
CLR Functions are (when used appropriately) faster because T-SQL is designed to perform set-based operations, NOT looping and math. It can do both adequately, but not necessarily all that well (compared to alternatives).
The .net framework's improved speed with looping, string manipulation and math calculations is what gives such an advantage to CLR functions. There seems to be an overhead involved with using them, but from what I've seen this is overcome at about 10,000 iterations of the function (tested with moderately complex math calculations). With < 10,000 iterations, the speed lost is negligible.
In wilsonfuqi's case, I would think the speed gained would be tremendous (over SQL Server methods anyway) because of how S-L-O-W looping is in SQL. However, some web hosts (well, mine anyway ;-) ) will not allow CLR to be enabled on their server.
If this is an option, it should probably be pursued in order to limit what is sent back from the database, but if it is not I would think that trimming the words off in ASP.net is far superior.
I would imagine that how CLR functions are written is irrelevant, because no matter the language they are compiled to the same framework.
Hope this clears things up a bit,
Alex
Ignorance of certain subjects is a great part of wisdom