While Loop

  • HI, Actually I need to update a Fact Table, I´m trying this statement

    while (select id_promotionSub FROM dbo.sipFTdataStage)=5

    begin

    update dbo.sipFTdataStage

    set net_price = 55

    end

    but I get an error message as follows:

    "Subquery returned mor than 1 value. This is not permitted when the subquery follows =. !=, ....or when de subquery is used as an expression"

    Please give me a hand, I really don´t understand what is hapenning,

    Thanks,

    Jorge

  • jeardilam (9/23/2009)


    HI, Actually I need to update a Fact Table, I´m trying this statement

    while (select id_promotionSub FROM dbo.sipFTdataStage)=5

    begin

    update dbo.sipFTdataStage

    set net_price = 55

    end

    but I get an error message as follows:

    "Subquery returned mor than 1 value. This is not permitted when the subquery follows =. !=, ....or when de subquery is used as an expression"

    Please give me a hand, I really don´t understand what is hapenning,

    Thanks,

    Jorge

    The select statement you have is returning multiple values. If you're trying to compare the id_promotionSub value to 5, then you should just write the update like this:

    UPDATE dbo.sipFTdataStage

    SET net_price = 55

    WHERE id_promotionSub = 5

    That's going to work a lot faster since it's not a RBAR (row by agonizing row) process.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

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

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