For years I used the same sort of thing, then I went to
where IsNull(@StudentID,StudentID ) = StudentID
but apparently COALESCE is preferable to isnull - not sure why in this instance. Its certainly good where you have several possible values, such as
select coalesce(val1,val2,val3) as mainvalue
Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP