how to update.

  • Hi,

    I have to update a table for following structure...................

    uid RMFP CMFP

    100

    400

    700

    800

    1100

    I want my result as follows...

    uid RMFP CMFP

    1150

    4012

    7180

    8190

    11020

    is there any query by which I can update my table as second form in only one step. Please reply me as soon as possible....

    Thanks in Advance

    Sunil..

  • Sure. Untested, but this should give you an idea.

    UPDATE SomeTable

    SET RMFP = CASE uid WHEN 1 THEN 15 WHEN 7 THEN 18 WHEN 8 THEN 19 ELSE 0 END,

    CMFP = CASE uid WHEN 4 THEN 12 WHEN 11 THEN 20 ELSE 0 END

    Why's it so important to do it in a single update?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • because of I have many records in my table....

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

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