By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,204 Members | 1,212 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,204 IT Pros & Developers. It's quick & easy.

Adding 1 to the previous highest value in a field

P: n/a
I want to append a number of records onto an existing table. Each record
will have an ID number (it is not an autonumber as it is too variable). It
is currently set as an integer field. I want to be able to work out what
the highest existing number in that field in the table is and start adding 1
to it for each record. In other words, I want a bunch of sequential numbers
with no gaps.

Is there a simple way to do this with a query?

dixie
Aug 16 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Dixie wrote:
I want to append a number of records onto an existing table. Each record
will have an ID number (it is not an autonumber as it is too variable). It
is currently set as an integer field. I want to be able to work out what
the highest existing number in that field in the table is and start adding 1
to it for each record. In other words, I want a bunch of sequential numbers
with no gaps.

Is there a simple way to do this with a query?

dixie

try

insert into mytable(id) select nz(max(id),0) +1 from mytable;

--
Smartin
Aug 16 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.