Hello everyone I have a quick questionThis is my first project where I had the need to write functions. My reason for doing so was to minimize the number of times the same lines of code will be executed as they will be used in other storedprocedures.Here is my Code:fx_MaterialBuildQuantity -- Add the SELECT statement with parameter references here SELECT dbo.fx_Material.EDCID , dbo.fx_Material.MatNumber , Sum(dbo.fx_Material.MaterialCost) AS Budget FROM dbo.fx_Material WHERE MaterialData.InitialDate BETWEEN '05/01/2005' and '05/31/2005' AND--@StartDate and @EndDate AND MaterialDetailsXref.MatNumber = MaterialData.MatNumber AND MaterialDetails.EDCID = MaterialDetailsXref.EDCID GROUP BY MaterialDetails.MatNumber , MaterialDetails.EDCID
Second Function fx_Material SELECT CAST(ROUND((SUM(dbo.DoorParts.Percentage * dbo.ScrewUsage.WeightID) * (dbo.MatDetails.MatNumber)),2) AS decimal(15,2)) AS Cost FROM Material INNER JOIN DoorINNER JOIN DoorParts ON dbo.Door.DoorID = dbo.DoorParts.DoorID ON Material.MaterialID = dbo.DoorParts.MaterialID INNER JOIN Weight ON dbo.Door.DoorID = dbo.Weight.DoorID INNER JOIN DoorUsage INNER JOIN MatDetails ON dbo.DoorUsage.EDCID = dbo.MatDetails.EDCID AND MatUsage.MatNumber = dbo.MatDetails.MatNumber ON dbo.Weight.WeightID = dbo.DoorUsage.WeightID WHERE dbo.MatDetails.MatNumber = @MatNumber GROUP By MatDetails.MatNumber
My problem is I need to pass in a value to a function inside of a function so that the main function can build its table? Many of these functions will be used in formulas so I know that I will run into this again, but at least I will have a better understanding of how to resolve it.