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
 Sub Query in select statement VS UDF

Author  Topic 

raky
Aged Yak Warrior

767 Posts

Posted - 2010-03-02 : 00:29:21

Hi,

Iam having a subquery in a select statement which brings some values as comma separated. For getting this is Subquery better in performance OR
UDF will give better performance ?? Please suggest.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-02 : 08:22:22
whats the subquery doing? is it using FOR XML approach?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2010-03-02 : 09:05:30
quote:
Originally posted by visakh16

whats the subquery doing? is it using FOR XML approach?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/





Yes, its using FOR XML Approach.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-02 : 09:07:55
see

http://sqlblog.com/blogs/adam_machanic/archive/2006/07/12/rowset-string-concatenation-which-method-is-best.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2010-03-02 : 09:15:27
Actually i need this comma separated values as a column in a huge select statement and also iam getting that comma separated string not directly from one table by joining 3 tables.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-02 : 09:22:59
so? even in that case if you go for UDF appraoch you still have to do joins dont you?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -