CONCATINATION

  • Hi

    using

    declare @a int,

    @b-2 int

    set @a=0

    while @a< 20

    begin

    set @a=@a+1

    print @a

    end

    i am getting result

    1

    2

    3

    .

    .

    .20

    but i want to concatenate like this 1,2,3,4,-------,20

    please suggest me

  • Hi,

    You would need a VARCHAR variable to hold your concatenated string, something like:

    DECLARE @concat VARCHAR(100)

    DECLARE @a INT

    SET @a=0

    SET @concat = ''

    WHILE @a < 20

    BEGIN

     SET @a= @a + 1

     SET @concat = @concat + CAST(@a AS VARCHAR) + ', '

    END

     PRINT @concat

    Is this what you were after?

    Ade



    Ade

    A Freudian Slip is when you say one thing and mean your mother.
    For detail-enriched answers, ask detail-enriched questions...[/url]

  • While writtnig stored procedure i stuck with the   concatinate strings so  I posted this question .

    Thanks for your suggestion 

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply