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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Sequential Updation Help

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, SUBITEM

For 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's

I 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 rows

Instead i need the output like the following :

ROW IETM ID SUBITEM
1 A 1 A1
2 A 2 A2
3 A 3 A3
4 A 4 A4
5 B 1 B1
6 B 2 B2
7 C 1 C1


In the current table the ID is all set to 1
can some one help me plz

Thanks 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
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-20 : 00:30:08
Duplicate, locking thread.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -