Seems like it's working better as I'm getting output now.
But this error is coming up:
Msg 4145, Level 15, State 1, Line 35
An expression of non-boolean type specified in a context where a condition is expected, near 'name'.
Msg 102, Level 15, State 1, Line 37
Incorrect syntax near 'o'.