August 4, 2010 at 11:15 pm
Hi,
I'm struggling to find a solution to this (very likely simple) problem:
I want to populate some rows in a table where the column RequestID is empty. I want the update query to start from the first row were RequestID is empty and continue downwards (RequestID will be incremented by '1'). Tried to use cursor but wasn't successful (the column RequestID gets populated with '1' all the way down!). Any help would be much appreciated:
Declare @i integer
set @i=0
declare CustList cursor for
SELECT * from FALSEDESCRIPTION WHERE RequestID =''
OPEN CustList
FETCH NEXT FROM CustList
While (@@FETCH_STATUS = 0)
Begin
set @i=@i+1
UPDATE FALSEDESCRIPTION SET RequestID=@i
FETCH NEXT FROM CustList
End
Close CustList
Deallocate CustList
August 4, 2010 at 11:51 pm
Duplicate post. No replies to this thread please. Direct replies to:http://www.sqlservercentral.com/Forums/Topic963971-1292-1.aspx
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply