• You should take a look at this article.

    How to Make Scalar UDFs Run Faster[/url]

    Here's an example on what you could do.

    CREATE FUNCTION dbo.tf_Points(

    @Grade AS VARCHAR(10),

    @Type AS INT

    )

    RETURNS TABLE

    AS RETURN

    SELECT CASE WHEN @Type IN(618, 617, 262)

    THEN CASE WHEN @Grade = 'DS*' THEN 180

    WHEN @Grade = 'DS' THEN 150

    WHEN @Grade = 'ME' THEN 105

    WHEN @Grade = 'PA' THEN 45

    WHEN @Grade = 'FL' THEN 0 END

    WHEN @Type IN(622, 623)

    THEN CASE WHEN @Grade = 'D*D*' THEN 360

    WHEN @Grade = 'D*D' THEN 330

    WHEN @Grade = 'DD' THEN 300

    WHEN @Grade = 'DM' THEN 240

    WHEN @Grade = 'MM' THEN 180

    WHEN @Grade = 'MP' THEN 120

    WHEN @Grade = 'PP' THEN 60

    WHEN @Grade = 'FL' THEN 0 END

    END

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2