Q:

using cast or convert function in stored procedure

why we have to use cast or cnvert function in 2nd and 3rd selecct statement, and what we achieve by casting or converting it to varchar, what varchar data type do in it exactly?   
DECLARE @mybin1 binary(5), @mybin2 binary(5)
SET @mybin1 = 0xFF
SET @mybin2 = 0xA5
-- No CONVERT or CAST function is necessary because this example 
-- concatenates two binary strings.
SELECT @mybin1 + @mybin2
-- A CONVERT or CAST function is necessary because this example
-- concatenates two binary strings plus a space.
SELECT CONVERT(varchar(5), @mybin1) + ' ' 
    + CONVERT(varchar(5), @mybin2)
-- Here is the same conversion using CAST
SELECT CAST(@mybin1 AS varchar(5)) + ' ' 
    + CAST(@mybin2 AS varchar(5))

A:

Casting it to a VarChar converts the data from a sequence of bytes to character text.  As Flip says, you can't directly concatentate the different types. Typically binary strings are for images, videos, streams, etc, where as varchar is usually string data like what is found in a text file.

