I assume "ID" is not some sort of auto incrementing record ID column?
It depends on your database. In an ms sql database, you could use "if not
exists ...". You could also count the number of records in the table and if it
is zero, execute some code.
--- ms sql database
if not exists (select someColumn from yourTable)
do something here...