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 |
|
itsarnie
Starting Member
18 Posts |
Posted - 2009-09-13 : 10:05:46
|
| Hi,I want to update a column for multiple rows in a table based on condition from the sample table.Table name is SMPLcolumn to update is SMPL_ID,SEQ_ID SMPL_ID SEQ_ID 1 5 2 566 5255 966 97 107 52I need to update(if duplicates found) SMPL_ID as 09+SMPL_ID for the records SEQ_ID=52so records for 52 will be like0966 52097 52Unable to update because of multiple updates.Please help.Thanks,ArnieThanks and regardsArnie, |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-09-13 : 10:33:32
|
If SMPL_ID is of type INT or other numeric type then it is not possible to have leading zeroes.Otherwise you can doupdate SMPLset SMPL_ID = '09' + SMPL_IDwhere SEQ_ID = 52and exists (select SEQ_ID from SMPL where SEQ_ID = 52 group by SEQ_ID having count(*) > 1)But I can imagine you won't do that for hard coded values like '09' and 52 only? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
itsarnie
Starting Member
18 Posts |
Posted - 2009-09-13 : 10:41:34
|
| Thanks so much for the reply.Actually there can't be any dupes within 52...We need to search for dupes across SEQ_ID...like:7 107 52and will have to make it7 10097 10Thanks,ArnieThanks and regardsArnie, |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-09-13 : 10:48:41
|
Sorry but now I understand nothing.On what condition becomes7 10 -> 7 107 52 -> 097 10? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
itsarnie
Starting Member
18 Posts |
Posted - 2009-09-13 : 10:57:05
|
| If a SMPL_ID exists for 52 and also for any other SEQ_ID, that SMPL_ID needs to be updated as '09'+SMPL_ID.Thanks,ArnieThanks and regardsArnie, |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-09-13 : 12:57:03
|
quote: Originally posted by itsarnie If a SMPL_ID exists for 52 and also for any other SEQ_ID, that SMPL_ID needs to be updated as '09'+SMPL_ID.Thanks,ArnieThanks and regardsArnie,
thats ok but how SEQ_ID for second record changed to 10? |
 |
|
|
|
|
|
|
|