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)
 Update Using Order by

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-04-21 : 08:01:04
Kassim writes "Declare @Rowno Numeric
set @Rowno =0
Update testdata Set @Rowno = Rowno = @Rowno+1
From testdata
order by Position

I would like to Update rows in sequence 1,2,3....N
Order by Position, above query works with out order by position,
but it work get the rowno in sequence. Can you help me in getting the row in sequence by ordering position .

regards,
Kassim."

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-04-21 : 08:03:03
You can't include ORDER BY in an UPDATE statement. The only way to accomplish what you're doing is to have a clustered index on the Position column.

It would help if you posted the exact table structure (CREATE TABLE statement), some sample data, and the results you want to get.
Go to Top of Page
   

- Advertisement -