Hello there
I am a very beginner..
I need to know if this is the write structure for doing this:
1. this func call for 4 other func: is it suppose to look like this?
2. with what i should replace the RETURNS int if its return date & int
thanks
ALTER FUNCTION [dbo].[StatisticsEx2_0Func]
(
@.Date_M_Y smalldatetime ,
@.FK nchar (20) ,
@.BizID int
)
RETURNS int
AS
BEGIN
DECLARE @.ResultVar int
set @.ResultVar = (SELECT
dbo.StatisticsEx_2_1_SingleMonthlySumFunc.A, dbo.Statistics_2_1_SingleAnnualAvgFunc.B, dbo.Statistics_2_1_AllGropsMonthlyTotalFunc.C, dbo.StatisticsEx_2_1_AllGroupsAnnualAvgFunc.D
FROM dbo.Statistics_2_1_AllGropsMonthlyTotalFunc, dbo.Statistics_2_1_SingleAnnualAvgFunc, dbo.StatisticsEx_2_1_AllGroupsAnnualAvgFunc, dbo.StatisticsEx_2_1_SingleMonthlySumFunc)
RETURN @.ResultVar
END
If you want to return more than one value then use Inline Table /Table Valued UDF.
If you use sql server 2005 then you can utilize the UDT (.NET Class) to return as Structure.
Create Function [dbo].[StatisticsEx2_0Func]()
Returns table
as
Return
(
Select 100 i, Cast('1/1/2007' as Datetime) d
)
go
Select * from [dbo].[StatisticsEx2_0Func]()
|||amm..
the "mother" func suppose to get 3 parm – every child func use 2 param out of the 3
then let the table
so...?
Create Function [dbo].[StatisticsEx2_0Func]()
Returns table
as
Return
(
Select
@.Date_M_Y smalldatetime ,
@.BizID int ,
@.FK
)
go
No comments:
Post a Comment