sql server - SQL Update with KEY FIELDS, but not changing they value -


i have table on ms sql, - tab1 key fields key1 , key2 , value field column1.

it has row values: key1 = a; key2 = b; column1 = 123;

i want fire sql update:

update tab1 set    key1 = a,        key2 = b,        column1 = 999  key1 =        , key2 = b 

i know right sql update statement be:

update tab1 set    column1 = 999  key1 =        , key2 = b  

but still... somehow affect update speed, indexes, etc. or ms sql clever enough deal this?

thank in advance!

i don't understand in case make sense use first query instead of second query...

you'll not have noticeable performance difference between both queries if have index on these columns, update process may have impact on , cause additional execution time (i'm not expert on indexes on every insert/delete/update on indexed column, modifications have impact on concerned index. may not big impact if update same value sql server not aware of until check made between values...).

i suggest use second approach if possible, you'll have more readable query , sure avoid misunderstanding when need come few months later work on code ;-)

as said, i'm not expert in opinion it's best practice keep simple when possible.

hope you.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -