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 |
raindear
Yak Posting Veteran
64 Posts |
Posted - 2013-12-02 : 14:16:55
|
HiI have a SQL table with 5000 rows in it. Some of the other SQL columns have different values but if I wanted to swap say 500 of the rows would it be something likeUPDATE CoupinsSET Name='test1,test2,test3'WHERE Name='test4,test5,test6'; I need basically to swap the Name value of these without affecting any other values. |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2013-12-02 : 14:19:54
|
Yes. You specify which rows to update by providing the appropriate WHERE clause. To see if your query is correct, run this first:select *from CoupinsWHERE Name='test4,test5,test6';Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2013-12-02 : 14:20:22
|
Why do you have comma separated values in the Name column? Shouldn't it be normalized instead?Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2013-12-02 : 14:59:51
|
I'm wondering if their objective is to change all 'test1' values to 'test4' and change all 'test2' values to 'test5' etc...Be One with the OptimizerTG |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2013-12-02 : 15:44:52
|
quote: Originally posted by TG I'm wondering if their objective is to change all 'test1' values to 'test4' and change all 'test2' values to 'test5' etc...
Oh! Yeah maybe. raindear, please clarify.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
|
|
|