Well this example might help you out in SQLServer 2005:
CREATE FUNCTION MyFunction ()
RETURNS @Tbl TABLE
(
StudentID VARCHAR(255),
SAS_StudentInstancesID INT,
Label VARCHAR(255),
Value MONEY,
CMN_PersonsID INT
)
AS
BEGIN
INSERT @Tbl
(
StudentID ,
SAS_StudentInstancesID ,
Label ,
Value ,
CMN_PersonsID
)
SELECT
StudentID ,
SAS_StudentInstancesID ,
Label ,
Value ,
CMN_PersonsID
FROM MyView -- where MyView selects (with joins) the same columns from large table(s)
RETURN
END
or you can have a check at this link as well, it has all the details you need.
http://msdn.microsoft.com/en-us/library/ms186755(v=SQL.90).aspx[
^]