Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Sequential Updation Help
 Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

9 Posts

Posted - 01/19/2009 :  19:38:30  Show Profile
hi ,

I am trying to update a table with incremental value, and i need some help.

table columns are:

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 inturn 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 :

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

Almighty SQL Goddess

38200 Posts

Posted - 01/19/2009 :  19:59:13  Show Profile  Visit tkizer's Homepage
Duplicate, locking thread.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server

Subscribe to my blog
Go to Top of Page
  Previous Topic Topic Next Topic  
 Topic Locked
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000