• Thanks Amar!

    I copied your code again, and now getting this message:

    Msg 170, Level 15, State 1, Procedure OPS_SP_DetailSPID, Line 12

    Line 12: Incorrect syntax near 'max'.

    Thank you very much!