|
-
Dec 8th, 2003, 09:52 AM
#1
Thread Starter
Addicted Member
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
-
Dec 8th, 2003, 06:19 PM
#2
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).
-
Dec 8th, 2003, 11:14 PM
#3
It depends upon the trigger. Is it an INSERT trigger, UPDATE trigger or what?
-
Dec 9th, 2003, 09:18 PM
#4
Thread Starter
Addicted Member
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
-
Dec 10th, 2003, 05:45 AM
#5
Hyperactive Member
That update statement will affect all the rows......
so the trigger for update will be fired.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|