private string BuildSql()
    {
        if (string.IsNullOrWhiteSpace(Table))
        {
            throw new InvalidOperationException("table name is missing");
        }

        if (FieldNames.Count == 0)
        {
            throw new InvalidOperationException("field names are missing");
        }

        return(new StringBuilder()
               .AppendInsert(Table, TemporaryTable, FieldNames, OutputFields)
               .Append(" ")
               .Append(SelectCommand.Build().CommandText)
               .ToString());
    }