azapovjednik 14 Newbie Poster

Hello,

I need to make a cursor, which would call a stored procedure to do something for me...

but the procedure needs dynamic parameters.
first one, it has to retrieve existing ID number from a table and the second parameter will be new value updated...
so, for every row, I need it to take existing ID value and replace it with a newly generated ascending number:

for example:
a123 -> 0001
b123 -> 0002
c123 -> 0003
c234 -> 0004

and so on and on...
This is what I did, but it is deleting rows! What am I doing wrong? thank you very much

DECLARE @IDENT char(16)
DECLARE @counter int
DECLARE @novo char(16)	
DECLARE c1 CURSOR 
FOR
SELECT ID
FROM table_name

OPEN c1

FETCH NEXT FROM c1
INTO @IDENT
SET @counter = 00001

SET @novo = @counter + 1
WHILE @@FETCH_STATUS = 0
BEGIN

	
exec sp_someProcedure 'table_name', @IDENT, @novo

	FETCH NEXT FROM c1
	INTO @IDENT

END

CLOSE c1
DEALLOCATE c1