I created a stored procedure which when passed nothing as parameter should return the entire table. But if the studentId is passed, then return her details. Something like t
You're trying to test for null using =, a comparison operator. If you're using ANSI nulls, any comparison against null is false.
Where @studentId is any value (or null) the following expressions are all false:
@studentId = null -- false
@studentId > null -- false
@studentId >= null -- false
@studentId < null -- false
@studentId <= null -- false
@studentId <> null -- false
So, in order to test for null you must use a special predicate, is null, i.e.:
@studentId is null