Get the last record in a dataset

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to move to the last record in a dataset and find out the next incremented number that will be created via an insert. I a have tried a count but this does not quite do as I need. As the number of records does not relate to the next incremented number. Could anybody help me with this please??

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
hi,

select top 1 fieldname from table order by fieldname desc

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

wrote in message news:[email protected]...
I am trying to move to the last record in a dataset and find out the next
incremented number that will be created via an insert. I a have tried a
count but this does not quite do as I need. As the number of records does
not relate to the next incremented number. Could anybody help me with this
please??
**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP &
ASP.NET resources...
 
ote in message news:[email protected]...
I am trying to move to the last record in a dataset and find out the next
incremented number that will be created via an insert. I a have tried a
count but this does not quite do as I need. As the number of records does
not relate to the next incremented number. Could anybody help me with this
please??

Ignacio's bit of SQL can help you in a single-user environment, assuming you
are not using any identity columns in the database. With multi-user or
identities, things get messier...

Mind if I ask what you want to do with the value? There might be a
different way to do what you're after.

Best Regards,

Andy
 
This can also help you:
select max(fieldname) from tablename

you can obtain the new value by using:

select max(fieldname)+1 from tablename

Note: assume the new value is last value plus 1
 
Back
Top