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 |
|
rookie_sql
Constraint Violating Yak Guru
443 Posts |
Posted - 2008-04-11 : 06:39:17
|
| Hi i have 2 rows of data in a table i'd like to update a column in one of the rows based on the other row. my data set is like this. I'd like to update the der_code * with the value of 10. prd_code der_code1000 101000 * |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-04-11 : 06:45:17
|
| [code]declare @t table( prd_code int, der_code varchar(10))insert @tselect 1000, '10' union allselect 1000, '*'update t1set der_code = t2.der_codefrom @t t1 join @t t2 on t1.prd_code = t2.prd_codewhere t1.der_code <> t2.der_code and t1.der_code = '*'select * from @t[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|
|
|