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
 UDF for millions of rows

Author  Topic 

ramyaraman
Starting Member

10 Posts

Posted - 2008-06-26 : 10:30:10
I have TableA.

ColA ColB
123 blah....

Table B has the data like below
ColA ColB
123 ABC
123 DEF
123 GHI

Table B may have one or more rows for 123. This is dynamic which is derived from another table.


I want the output as

123, blah, ABC ** DEF


So on my select I call a function

funct(123)

this function will loop thru TableB and

return ABC ** DEF

This works fine, except that it takes longer since I have 5 different functions doing similar stuff with different tables. Having millions of rows in TAbleA is making the query run very slow. What is the best method to do this?



madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-26 : 10:33:35
Which version of SQL Server are you using?
Follow these methods
http://sqlblog.com/blogs/adam_machanic/archive/2006/07/12/rowset-string-concatenation-which-method-is-best.aspx
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81254

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

ramyaraman
Starting Member

10 Posts

Posted - 2008-06-26 : 10:36:29
It is sqlserver 2000
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-26 : 10:40:13
Did you use the code similar to the one posted at Link1?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

ramyaraman
Starting Member

10 Posts

Posted - 2008-06-26 : 11:26:40
Yes, I did. I was using cursor on the function to do this. Now I changed it to the case similar on the link. Still there is no improvement in performance
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2008-07-04 : 04:07:29
Have you got an index on ColA of your tableB?

If your function is having to table scan every time then your performance will be awfull.



-------------
Charlie
Go to Top of Page
   

- Advertisement -