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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 update query -sql server 2005

Author  Topic 

paramu
Posting Yak Master

151 Posts

Posted - 2009-06-01 : 09:04:19
Hi,

I want to update the table like the following manner.

Field "Item_type" is having the data's

ASM
BSD
RVF
ASM
TYP
BSD
ASM

But I want to update like the following

ASM1
BSD1
RVF1
ASM2
TYP1
BSD2
ASM3

like wise ...means when the value is found again, need to increase the counter

update itm_code set itm_code=count(itm_type) from item_master....????



Paramu @ PARANTHAMAN

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-06-01 : 09:17:59
make use of row_number()


select item_type + convert(varchar(10), row_number() over (partition by item_type order by item_type))
from item_master



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

paramu
Posting Yak Master

151 Posts

Posted - 2009-06-01 : 11:26:33
Not Enough.
Nedd to repair it........

"select itm_code,substring(itm_description,1,3) as Itm_type,substring(itm_description,1,3)+convert (varchar(10), row_number() over (substring(itm_description,1,3)) order by substring(itm_description,1,3)) as Record_number from itemmst"

Thanks

Paramu @ PARANTHAMAN
Go to Top of Page
   

- Advertisement -