How to make += in updates.

  • I am trying to update a field , which is defined as an INT.

    UPDATE dbo.tableexample set minutes = minutes + 2160 where ID = 23654

    If the old value was 1000, the new should be 1.000 + 2610 = 3610.

    But it seems like MSSQL is doing something quite different.

    How to

    Best regards

    Edvard Korsbæk

  • Very strange.

    Make sure there is no trigger on the table that might affect UPDATEs.

    Make sure ID 23654 only matches one row in the table (so that you're not just seeing the wrong results from a different row).

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.

  • But it seems like MSSQL is doing something quite different

    What specifically are you seeing for input vs. output?

  • Sorry, sorry, sorry...

    For wasting your time.

    the UPDATE dbo.tableexample set minutes = minutes + 2160 where ID = 23654 did exactly what it was supposed to.

    After that i did something wrong to a field called duration, which confused me.

    Best, and somewhat humple regards

    Edvard Korsbæk

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

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