Hi Folks,
I'm trying to generate some sql that is used to calculate some final scores -> think kids at school and their end of year scores.
I was going to have about 5 or so Scalar UDF's that, accept some simple values (eg. current score, subjectid, whatever) and then spit out a decimal value.
eg.
CREATE FUNCTION [dbo].[GetRatingModifier]
(
@ExamScore DECIMAL(6, 2),
@Project1Score DECIMAL(6, 2),
@Project1Score DECIMAL(6, 2),
@Project1Score DECIMAL(6, 2),
@SubjectTypeId TINYINT
)
RETURNS DECIMAL(8,5)
AS
BEGIN
DECLARE @Score DECIMAL(8,5)
SELECT @Score = (CASE @Project1Score
WHEN 1 THEN 10
WHEN 2 THEN 12.4
....) +
(CASE blah.. u get the drift)..
RETURN @Score
END
The logic has only maths. No select xxx from table yyy etc..
So, is this ok to do with regards to performance?