I have been doing the below statement to populate a column called "o_rowid" with a number. The table "AP_Dept1113" has over 80,000 rows of data. After I do an import into this table this column is <NULL> where the new data is. It has to have a row number to accomplish what we do with our front end software. The statement runs for over three hours, but never finishes correctly. Does anyone know a better way to assign a number + 1 to this column?
declare @currrow char(19)
declare @counter int
declare @numrows int
declare @numrows2 char(19)
declare x cursor for select count(*) from AP_Dept1113
open x
fetch x into @numrows
close x
select @numrows2 = convert( char(19), @numrows )
declare stamper cursor for select o_rowid from AP_Dept1113 for update of o_rowid
select @counter = 1
open stamper
while (@numrows > 0)
begin
fetch stamper into @currrow
print @currrow
update AP_Dept1113 set o_rowid = convert ( char(10), @counter) where current of stamper
select @counter = @counter + 1
select @numrows - 1
end
declare @currrow char(19)
declare @counter int
declare @numrows int
declare @numrows2 char(19)
declare x cursor for select count(*) from AP_Dept1113
open x
fetch x into @numrows
close x
select @numrows2 = convert( char(19), @numrows )
declare stamper cursor for select o_rowid from AP_Dept1113 for update of o_rowid
select @counter = 1
open stamper
while (@numrows > 0)
begin
fetch stamper into @currrow
print @currrow
update AP_Dept1113 set o_rowid = convert ( char(10), @counter) where current of stamper
select @counter = @counter + 1
select @numrows - 1
end