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??
hi,
select top 1 fieldname from table order by fieldname desc
cheers,

Signature
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
> 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...
GirishKumar - 03 Aug 2004 11:35 GMT
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

Signature
Girish Kumar
ICICI Infotech
"Ignacio Machin ( .NET/ C# MVP )" wrote:
> hi,
>
[quoted text clipped - 12 lines]
> > Comprehensive, categorised, searchable collection of links to ASP &
> ASP.NET resources...
> 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