procedure SaveQueryResultToTable(AQuery: TQuery; AFileName: TFileName);
var
h : HDBICur;
ph : PHDBICur;
begin
AQuery.Prepare;
Check(dbiQExec(AQuery.StmtHandle, ph));
h := ph^;
Check(DbiMakePermanent(h, PChar(AFileName), True));
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Query1.DatabaseName := 'DBDEMOS';
Query1.SQL.Clear;
Query1.SQL.Add('Select Distinct Category from Biolife.db');
SaveQueryResultToTable(Query1, ExtractFilePath(Application.ExeName)+'RES.DB');
end;