I want to create this function:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION fnCalcTrimmean
(
@starttime datetime,
@endtime datetime,
@percentile decimal(18, 2),
@platform varchar(100),
@stage varchar(50)
)
RETURNS @result TABLE
(
TimeResult DECIMAL(18, 2)
)
AS
BEGIN
INSERT INTO @result
EXEC spCalcTrimmean @starttime, @endtime, @percentile, @platform, @stage
RETURN
END
But when I try create the function the error appears:
Msg 443, Level 16, State 14, Procedure fnCalcTrimmean, Line 17
Invalid use of a side-effecting operator 'INSERT EXEC' within a function.
[UPDATE]
- The procedure spCalcTrimmean return ALWAYS a single value
What can I do to create a function like this?
Thanks :)