• haiao2000 (4/17/2013)


    rama.king127 (4/17/2013)


    A string contains 3,4 suppose I want to store 3 in one parameter and 4 in another parameter similar in c# like arr[0] and arr[1]? how can i achieve it

    Think outside the box, the sql way like this...

    set nocount on;

    declare @sqlArray table (id int identity(1,1), item int)

    insert into @sqlArray(item)

    select 3 union all

    select 4;

    declare @x int=1, @arrayLength int, @curItem int

    select @arrayLength=MAX(id) from @sqlArray;

    --now loop thru your array =)

    while @x <= @arrayLength begin

    select @curItem = item from @sqlArray where id=@x;

    print @curItem;

    set @x= @x+1;

    end

    Gosh, no. Think outside the box. 😉 Don't use RBAR for this.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)