Results 1 to 5 of 5

Thread: UPDATE field to same value?

  1. #1

    Thread Starter
    Addicted Member Phenix's Avatar
    Join Date
    Sep 2002
    Location
    Near A Cube
    Posts
    228

    Question UPDATE field to same value?

    In MS SQL Server 2000:
    If I perform an UPDATE on a field that already has the value I am setting it to in the UPDATE statement, will the value be set again and will triggers refire?

    Or will only the fields where there needs to be a change be affected?

    For instance; lets say I have:
    Table1
    Id Parameter
    1 A
    2 B
    3 A

    UPDATE Table1 SET Parameter = 'B'

    instead of

    UPDATE Table1 SET Parameter = 'B' WHERE Parameter != 'B'
    Circa 1995
    Engineer - I think we should put our website address on our paper catalogs.
    Vice President - Don't get too excited about this internet thing.


    I am sorry, but the Oracle was mistaken. You cannot help us.
    -Matrix video game


    I'm doing a (free) operating system (just a hobby, won't be big and professional like gnu) for 386(486) AT clones. ... and it probably never will support anything other than AT-harddisks, as that's all I have :-(.
    -Linus


    Question. Do you know that the character "?" means I'm asking a question? Question. Do you know that spoken inflection also provides the same cue? So please don't say, "Question" before you ask your question. Believe me I'll know.

    That said, I would have said this first if it had to precede what I'm telling you now. Having said that, what I'm telling you now is the same thing I just said about the annoying phrases "That said" and "Having said that".


    Are you threatening me, Master Jedi?
    -Chancellor Palpatine

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    Each record, including Id 2, will be affected by the first Update statement. Either way the trigger fires only once (triggers do not fire for each record being updated).

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    It depends upon the trigger. Is it an INSERT trigger, UPDATE trigger or what?

  4. #4

    Thread Starter
    Addicted Member Phenix's Avatar
    Join Date
    Sep 2002
    Location
    Near A Cube
    Posts
    228
    MySQL says that MySQL only UPDATEs the values that need changing, so I thought I'd ask for MS SQL Server.

    I had a brilliant idea this morning...to RTFM. But I didn't have time today.

    I didn't write the triggers or stored procedures (and I've never written any), so I'm not familiar with them. But from what I could gather (when I looked at them about a month ago), there are both INSERT and UPDATE as well as changes to a different table which also has its own triggers and SP's. I'll take a closer look when I get the chance.
    Circa 1995
    Engineer - I think we should put our website address on our paper catalogs.
    Vice President - Don't get too excited about this internet thing.


    I am sorry, but the Oracle was mistaken. You cannot help us.
    -Matrix video game


    I'm doing a (free) operating system (just a hobby, won't be big and professional like gnu) for 386(486) AT clones. ... and it probably never will support anything other than AT-harddisks, as that's all I have :-(.
    -Linus


    Question. Do you know that the character "?" means I'm asking a question? Question. Do you know that spoken inflection also provides the same cue? So please don't say, "Question" before you ask your question. Believe me I'll know.

    That said, I would have said this first if it had to precede what I'm telling you now. Having said that, what I'm telling you now is the same thing I just said about the annoying phrases "That said" and "Having said that".


    Are you threatening me, Master Jedi?
    -Chancellor Palpatine

  5. #5
    Hyperactive Member sw_is_great's Avatar
    Join Date
    Nov 2003
    Posts
    330
    That update statement will affect all the rows......
    so the trigger for update will be fired.
    Regards

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width