• I really appreciate you for your answer thanks. And the output was the same as i was thinking.

    Since i am a newbie , i am having some problem while trying to understand your code.

    Following are the area which are new to me i would really appreciate if you could spare some time and help me with them. Either you can provide some link or you can explain them.

    SELECT (SELECT N

    FROM (SELECT TOP (LEN(@number))

    SUBSTRING(CAST(@number AS VARCHAR(19)),N,1)

    FROM (VALUES(1),(2),(3),(4),(5),(6),(7),(8),(9),

    (10),(11),(12),(13),(14),(15),(16),(17),

    (18),(19))a(N)

    WHERE N <= (LEN(@number))

    ORDER BY N DESC) b(N)

    FOR XML PATH(''), TYPE).value('.', 'VARCHAR(19)');

    In the above example we have not define the variable 'a' , 'b' & 'N' and then also we are using it.

    Please help me out with the above question.