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 2008 Forums
 Transact-SQL (2008)
 UserDefinedFunction

Author  Topic 

lexiz
Starting Member

17 Posts

Posted - 2010-10-20 : 01:36:18
Hi all.

I always had speed issues with functions when I used them years ago. one of my developers is using a function to return a set of records which i then need to manipulate again in stored procs and views.

Am I better off, rather than returning a set of records from the UDF, getting the udf just to return the single varchar(5) which I can then use to filter the main table and produce the same set of records (or a smaller set if I the additional filters i need)


just in case this helps......
ALTER FUNCTION [dbo].[GetTranslatedStrings]
(@Cult varchar(5),@CategID int)
RETURNS
@TransTbl TABLE
( RowNum int,Title varchar(100),
[Description] varchar(300),
Help_text varchar(300))
AS
BEGIN
Declare @AvailCult varchar(5) =dbo.GetAvailableCulture(@Cult,0)
IF @AvailCult IS NOT NULL
Insert into @TransTbl Select RecNumb,Title,[Description],HelpText
from Dictionary Where Local_culture =@Cult And CategoryID =@CategID
Order by RecNumb
RETURN
END

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-10-20 : 02:33:46
Seems like there isn't any magic in this function.
I don't know the context where it is used but it looks to me that it is possible to work without that function...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -