• shahsn11 (8/3/2012)


    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.

    'a' , 'b' & 'N' aren't variables.

    'a' & 'b' are alias for tables

    'N' is an alias for the unique field of 'a' & 'b'

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2