Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
codism
Starting Member
11 Posts |
Posted - 2007-03-06 : 11:28:01
|
I wrote a script to switch two fields for certain rows:quote: declare @tmp intupdate my_tableset @tmp = field1, field1 = field2, field2 = @tmpwhere my_condition = true
The above script works fine while I am worrying it is only correct when the execution order for the three assignment statements is guaranteed. I do not want to use a temporary table because of performance concerns. Can any one give me the confidence by any suggestion or any document that makes the script always correct?Thanks in advance. |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-03-06 : 11:30:10
|
| [code]update my_tableset field1 = field2,field2 = field1where my_condition = true[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
codism
Starting Member
11 Posts |
Posted - 2007-03-06 : 12:10:58
|
| You code works! Can you point me the article talking about the principle? |
 |
|
|
|
|
|