Board index » delphi » SQL Query to put in a TQuery

SQL Query to put in a TQuery

Hi.

I need to make this Query.

I have a table with a long int type field. I need to know a "free value" of
this field to make an insert command. How can i know what is the first value
that is free?

TIA

 

Re:SQL Query to put in a TQuery


Here is a query someone at our office came up with that comes pretty close:

select min(recordid-1) from MyTable where recordid -1 not in (select
recordid from MyTable)

The main difference is that it doesn't give you the "first" value that is
free. Suppose you had these values:

0
1
2
8
9

It would return back 7. I think you wanted it to return 3 in this situation.

Bryan

Quote
"Milhouse" <milho...@milhouse.com> wrote in message news:3b611e45_2@dnews...
> Hi.

> I need to make this Query.

> I have a table with a long int type field. I need to know a "free value"
of
> this field to make an insert command. How can i know what is the first
value
> that is free?

> TIA

Other Threads