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 2008 Forums
 Transact-SQL (2008)
 Data ordering

Author  Topic 

juicyapple
Posting Yak Master

176 Posts

Posted - 2010-06-25 : 03:43:42
Hello,

Anyway to reorder the record no. without using cursor loop?

Select Record_No From tblRecord
Record_No
2
3
4
6
7

Recorder the data ascending and update the record no. to

Select Record_No From tblRecord
Record_No
1
2
3
4
5


madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-06-25 : 03:49:42
You just need a select statement instead of update

select row_number() over (order by col) as recno from your_table

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

juicyapple
Posting Yak Master

176 Posts

Posted - 2010-06-25 : 03:57:09
quote:
Originally posted by madhivanan

You just need a select statement instead of update

select row_number() over (order by col) as recno from your_table

Madhivanan

Failing to plan is Planning to fail



If I still need to update the Record_No?
Go to Top of Page

juicyapple
Posting Yak Master

176 Posts

Posted - 2010-06-25 : 04:17:17
I get the idea already.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-06-25 : 04:58:31
quote:
Originally posted by juicyapple

I get the idea already.


What is the idea?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -