July 9, 2009 at 1:01 am
Dear All,
I am very curious to know whichone will give the better performance either Funtion or Inline Query.
My requirement is
i am having a query(which will return millions of records) in which i have called funciton that will return the comma seperated value for the given id
Here is the funciton code.
CREATE FUNCTION [dbo].[fn_SplitByComma]
(
@Value Bigint
) RETURNS varchar(8000)
AS BEGIN
DECLARE @Result varchar(8000)
SET @Result = ''
SELECT @Result = @Result + CASE WHEN LEN(@Result)>0 THEN ', ' ELSE ''
END + <
FROM <
WHERE id= @Value
RETURN @Result
END
.
I am using this in a select query which will return millions of records
as
SELECT id, dbo.fn_SplitByComma(id) as commaseperatedvalue
FROM <
Could you please tell me whichone is the best one
what if i use inline query instead of function..
SELECT id,
(
SELECT CASE WHEN LEN(<
FROM <
WHERE id= @Value
)
commaseperatedvalue
FROM <
Thanks,
Santosh
July 19, 2009 at 10:50 pm
See the following for an answer...
http://www.sqlservercentral.com/articles/Test+Data/61572/
And please stop double and triple posting.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply