Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 performances of user defined function.

Author  Topic 

mathmax
Yak Posting Veteran

95 Posts

Posted - 2008-07-16 : 10:50:16
Hello,

I've a program that send queries with functions that are not TSQL valid. I should convert those functions so that SQL server understand them. I see two possible approaches:
-Convert the functions name on the client side in order to send valid SQL queries to the database.
-Create user defined function on the server that redirect to the TSQL functions.

The second approach is a bit more simple to deploy, but I wonder if it's less efficient...

Here is an example of conversion :
alltrim(astring) should be converted to ltrim(rtrim(astring))

Which of the above solutions to you advice me?

regards,

mathmax

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-16 : 10:56:01
i think first option is better so that sql server will always get valid functions for processing.The other functions can be replaced with help of some string manipulation functions available in front end.
Go to Top of Page

mathmax
Yak Posting Veteran

95 Posts

Posted - 2008-07-16 : 11:07:13
Is there a significant difference of performance when SQL server process on valid functions rather than on user defined functions?
On the other side, my client machines aren't very powerful and translations of functions could be a bit slow...
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-07-16 : 23:38:39
Should use system functions whenever possible.
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2008-07-17 : 01:38:25
You've also got to consider how/whether the Query Optimizer will take into account the UDF when deciding on the query plan

Jack Vamvas
--------------------
Search IT jobs from multiple sources- http://www.ITjobfeed.com
Go to Top of Page

mathmax
Yak Posting Veteran

95 Posts

Posted - 2008-07-17 : 08:43:29
Yes it's quite easy because the epxression I have to convert into SQL is parsed on the client side.
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2008-07-19 : 05:07:46
OK , I was thinking more about UDFs within the sql server itself

Jack Vamvas
--------------------
Search IT jobs from multiple sources- http://www.ITjobfeed.com
Go to Top of Page
   

- Advertisement -