Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Sql 7 query update rowid

Status
Not open for further replies.

denimblue

Technical User
Sep 23, 2002
8
US
I just did an import into an exisiting table with rows of data. I now have my new data in the table (no rowid assigned). I'm looking for a simple rowid update query.
 
I am not sure what you are looking for.


Update tablename
set tablefield1 = x
where something = something.

?????????????

Is that what you need???????
 
This is what I did
Imported new data
4099 rows
They import without a rowid assigned
I performed the following:

declare @currrow char (10)
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

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 > o)
begin

fetch stamper into @currrow

print @Currrow

update AP_Dept1113 set o_rowid = convert ( char(19), @ counter ) where current of stamper

select @counter = @counter + 1
select @numrows = @numrows - 1

end

This ran for quit awhile, I stopped it; then ran:

select count(*) from AP_Dept1113

got: 63562

select * from o_rowid_ident

got:

rowid rowwidd
76309 150000

I did a query
select o_rowid, number_of_dups = count (*)
from AP_Dept1113
group by o_rowid
having count (*) >1
got: 1613 duplicate rows?????

I still need help finding a better way to add rowid's to existing data. But more so, need assistance fixing my duplicate rows. Can you or anyone help?
Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top