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
 SQL Server Development (2000)
 Changing a Sequential Number

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-02-04 : 07:10:50
Anthony writes "I love your website guys. I sure hate to cop out on this one, but I am a bit stumped as to the most logical way of changing the order of sequential numbers using either a trigger or a stored procedure.

For example, I have a table like this:


primary_key group_order
----------- -----------
10 1
20 2
30 3
40 4
50 5


I would like to change primary_key (40) to group_order (2) using
(UPDATE tbl_example SET group_order=2 WHERE primary_key=40)
so that the table ends up looking like this:


primary_key group_order
----------- -----------
10 1
40 2
20 3
40 4
50 5


It looks like a cascade of some sort could do the trick, but everything I have tried looks like way too much code for something that seems so simple. Do you have any suggestions?

Btw... I am using SQL Server 2000 (SP3)

Thanks,

-Tony"

X002548
Not Just a Number

15586 Posts

Posted - 2003-02-04 : 09:01:38
What happend to PK '30'?

Go to Top of Page
   

- Advertisement -