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

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

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

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

tkizer
Almighty SQL Goddess

USA
37142 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
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.05 seconds. Powered By: Snitz Forums 2000