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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 calling a user-defined function in a query

Author  Topic 

iamsmahd
Yak Posting Veteran

55 Posts

Posted - 2005-07-20 : 06:06:51
Hi there.
I have a user-defined function (dbo.fn_StudCount) which wanna to use it within a select statement.
when I run my query without the function it returns result set very fast (in query analyzer) but as I run my query with the function it slows very down ! :

======my query without the function======
select x,y,z
from table1,....
=========================================

=====my query with the function==========
select x,y,dbo.fn_StudCount(x) as sc
from table1,....
=========================================

now how can I improve my query ?what is your idea?

thank you very much

sonia

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-07-20 : 06:19:15
what does your function do?
if it's a complex function of course it will slow the query down.
functions execute for each row. so if you have 100.000 rows it wil execute 100.000 times.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

iamsmahd
Yak Posting Veteran

55 Posts

Posted - 2005-07-21 : 06:09:23
Dear Friend,
my function is a computational one and hasn't got a complex process.

So what is your solution?Do you have any opinion for improving the select statement?

Thanks in advance....


sonia
Go to Top of Page

iamsmahd
Yak Posting Veteran

55 Posts

Posted - 2005-07-21 : 06:13:53
Dear Friend,
my function is a computational one and hasn't got a complex process.

So what is your solution?Do you have any opinion for improving the select statement?

Thanks in advance....


sonia
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-07-21 : 06:19:00
this tells me nothing...
show us the function.



Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -