I am trying to use a temp table within user defined function to calculate some fields getting the totals., i ma getting an error message i cannot use temp tables within user defined functions, is there any other way, Please help.CREATE FUNCTION [dbo].[UDF_getEFundAllocatedAmount] ( @efundid int, @Elementid int)RETURNS bitASBEGINDECLARE @AllocatedFundAmt floatCREATE TABLE #TempEFundAllocated(efundid int,eFundAmt float);Insert INTO #TempEFundAllocated(efundid,eFundAmt)(Select @efundid, isnull(Month1,0) + isnull(month2,0) + isnull(month3,0) from Tbl_RevenueCashFlow where Fundid=@efundid and elementid=@Elementid)SET @AllocatedFundAmt = 0SET @AllocatedFundAmt = (Select isnull(sum(eFundAmt),0) from #TempEFundAllocated)RETURN @AllocatedFundAmt;END
Thank you very much for the helpful info.