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 |
shabad
Starting Member
9 Posts |
Posted - 2009-01-19 : 19:39:20
|
hi ,I am trying to update a table with incremental value, and i need some help.table columns are:IDENTITY, ITEM, DESC, ID, SUBITEMFor occurance of each subitem i need the values for the Item from 1.The table is already populated with ID as 1 , and it has many ITEM's which inuten has many SUBITEM'sI wrote the update statement but get the max(id) dint work , i think my code is not correct.select @max_id = max(id) from Table1 where item = abcde UPDATE TABLE1 SET id = @max_id+1 from Table1 where table1.item = abcde This code updates the total occurances of each item for all the rowsInstead i need the output like the following :ROW IETM ID SUBITEM1 A 1 A12 A 2 A23 A 3 A34 A 4 A45 B 1 B16 B 2 B27 C 1 C1In the current table the ID is all set to 1can some one help me plzThanks in Advance |
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-01-19 : 22:54:11
|
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=118101 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|