SQLServer Stored Proc. not working as intented

Printable View