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 |
Dreamd
Starting Member
2 Posts |
Posted - 2013-03-22 : 05:44:03
|
Hi i need to update a table but i dont know how to do it right.. table:product_id; description; Tkey100 ; xxx ; 100201 ; xxy ; 2011201 ; aaa ; 12011100 ; bbb ; 1100'FFFF' ; zzz ; 'GENERIC'id like to set column "Tkey" like SET Tkey = Tkey WHERE product_id - 1000 EXISTS in product_idafter the update the table should look like :product_id; description; Tkey100 ; xxx ; 100201 ; xxy ; 2011201 ; aaa ; 2011100 ; bbb ; 101'FFFF' ; zzz ; 'GENERIC'can someone help me please?sorry for my bad english |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-03-22 : 05:47:08
|
[code]UPDATE tSET t.Tkey = t1.TkeyFROM table tINNER JOIN table t1ON t1.product_id = t.product_id -1000[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
Dreamd
Starting Member
2 Posts |
Posted - 2013-03-22 : 06:27:28
|
Thank you visakh16 ! |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-03-22 : 06:34:45
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|