May 2, 2007 at 9:53 am
Hi guys, is it possible to create a single function that returns multiple value's?
if possible can anyone share the syntax doing a similar task.
ex. I a table with records of multiple occurences linked to a single primary key in the parent table.
i want to create a select query within a function that is able to concatenate multi values in each column which is then returned to the call function.
thx in advance for any help/suggestions
May 2, 2007 at 2:56 pm
But according to this:
"i want to create a select query within a function that is able to concatenate multi values in each column which is then returned to the call function"
you actually need single output value function.
Can you explain more explicitly?
_____________
Code for TallyGenerator
May 2, 2007 at 3:50 pm
ooh sorry, what i'm actaully saying is that i want the function to return multiple columns (Multiple output value function).
May 2, 2007 at 4:30 pm
Still not clear what are you after.
You may use table function (you may find in amongst function templates in Query Analyzer).
But I would suggest to consider using a view instead.
Sorry, I need more information to be more specific.
_____________
Code for TallyGenerator
May 3, 2007 at 1:24 pm
you could insert your values into a table and return the table.
declare a table variable in the function, insert ur multiple values into that table variable and return thetable variable.
May 4, 2007 at 10:02 am
If we are talking text data and you want to display the result in multiple lines you might add a char(10)+char(13) to each result, and concatenate everything into one big string.
In a web page or excel-cell this will display as several lines...
regards
karl
Best regards
karl
May 4, 2007 at 5:28 pm
PLEASE... take the time to show some data before and after the function gets done with it... it sounds like you want a table function but we can't tell for sure.
--Jeff Moden
Change is inevitable... Change for the better is not.
May 7, 2007 at 8:35 am
CREATE FUNCTION dbo.fnTest (@RunDate datetime)
RETURNS @retTable TABLE
(
col1 int,
col2 varchar(10),
col3 varchar(40),
..
..
..
..
)
AS
--
Begin
INSERT INTO @retTable(col1, col2, col3,..)
SELECT val1, val2, val3,..
FROM table1
--
RETURN
END
Hope this helps.....
May 7, 2007 at 9:30 am
Kewl, thx swamy
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply