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)
 Iterating through the set without Cursors

Author  Topic 

azamsharp
Posting Yak Master

201 Posts

Posted - 2007-08-09 : 17:06:40
Hi,

I need to iterate through a table of data and update some fields with a sequential value.

The @TestID returns 4-5 rows which are the problems of that test.

WHILE(@Counter <= @MaxProblems)
BEGIN

UPDATE tblTestDeck
SET ProbNo = @Counter
WHERE tblTestLU_ID = @TestID
AND Active = 1

SET @Counter = @Counter + 1

END

But how can I get one row at a time so I can update it with my sequential value.
Without cursors!


Mohammad Azam
www.azamsharp.net

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-08-09 : 17:10:12
What do you mean by >> how can I get one row at a time so I can update it with my sequential value

one row at a time from where? Can you provide some sample data and what you are trying to update it with? If its just serial numbers you are trying to update there are perhaps easier ways to do it. Also mention any PK columns in the table.


Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page
   

- Advertisement -