August 11, 2011 at 11:23 pm
Dear Sir,
I have written a function which return multiple value but I want to store in a variable but how to store plz. help ..
[Code]
CREATE FUNCTION dbo.GetClg_Rate
(@Co As Varchar(02),
@Itemcd As Varchar(10),
@Date As Datetime)
RETURNS NUMERIC(14,4)
AS
BEGIN
--This Query Getting closing rate of last date within given period
--!
DECLARE @Retval AS NUMERIC(14,4)
SET @Retval=(SELECT CLNG_RATE FROM RATES
WHERE ITEMCD=@Itemcd AND
[DATE]=(SELECT MAX([DATE]) FROM RATES
WHERE [DATE]<=@Date AND CLNG_RATE<>0))
--!
RETURN (@Retval)
END
[/Code]
August 12, 2011 at 12:31 am
How are you currently using this function and how do you envision using this function?
August 12, 2011 at 10:05 am
By definition a function canNOT return more than one value. That value could be a table of course which is referred to as a TVF (table valued function).
Look at the online documentation about specifics.
If you have specific usage questions we can help.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy