The SQL Server (2000/2005) function gets the table name and the field name as parameters and returns results from a dynamic query within the function. The results should be
I'm not sure how this works with functions, but if you have a Stored Procedure that returns a resultset, you can insert that into a table variable using INSERT EXEC statements.
INSERT @TableVariable
EXEC spYourProcedure
As long as the fields match that will work. Otherwise you can use:
INSERT @TableVariable (FieldInSp1, FieldInSp2)
EXEC spYourProcedure
This way you can pass data between stored procedures. See this page on INSERT EXEC Statements for some extra information.