is there a loop construct in Access SQL

A

asc4john

Is there a loop construct in Access SQL or is there a way to simulate
one? Can I add a number of records to a table with one of the fields
sequentially numbered? Without using VBA.
INSERT INTO tblTable
line VALUES ( line + 1 while line < 64) ;
 
D

David Cox

http://groups.google.co.uk/advanced_search?q=&ie=UTF-8&oe=UTF-8&hl=en&

search terms:-

access sql "custom autonumber"

There is no loop construct in Access SQL. You have to think in terms of sets
of data.

For each item in the un-numbered set find the maximum in the numbered set,
add 1 to it, and assign that as the number. It takes some effort to get your
head around that way of looking at things, but the insight is worth it.

good luck
 
M

Michel Walsh

Another solution is to use a driver table: Iotas, one field, its primary
key, iota, with values from 0 to 999 (or whatever suits your needs).


INSERT INTO tableName(fieldName) SELECT iota+startingValue FROM iotas WHERE
iota <64



Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top