Query that returns the column names that have never been used

I'm going to drop out, this is a complete waste of everyone's time.

The initial post implies a single table in Access
Around post 35 - the OP says he never uses the JET/ACE databases with the implication it is actually sql server. Leaving everyone barking up the wrong tree for 33 posts.

and the code he/she/they/them quotes just lists all the fields in a table, not those without any values which is the requirement of the original post
 
But the question asked is a query on a generic db,

In the case of a generic DB, you cannot depend on vendor-specific extensions of SQL. Which means you are limited to ANSI SQL Standards. For that case, the answer is NO you cannot do this in a simple, generic-SQL query.

The reason is that generic SQL does not deal with metadata, and the questions you are asking are based on metadata.

IF you name a specific SQL engine, you certainly might find that some metadata extensions have been built into the vendor's SQL. But each case is different. So for the generic question, No - you can't do what you asked.
 
In the case of a generic DB, you cannot depend on vendor-specific extensions of SQL. Which means you are limited to ANSI SQL Standards. For that case, the answer is NO you cannot do this in a simple, generic-SQL query.

The reason is that generic SQL does not deal with metadata, and the questions you are asking are based on metadata.

IF you name a specific SQL engine, you certainly might find that some metadata extensions have been built into the vendor's SQL. But each case is different. So for the generic question, No - you can't do what you asked.

Ok, this is accettable, with Ansi Sql is not possible
With Microsoft Sql Server did you think is possible?
 
I'm going to drop out, this is a complete waste of everyone's time.

The initial post implies a single table in Access
Around post 35 - the OP says he never uses the JET/ACE databases with the implication it is actually sql server. Leaving everyone barking up the wrong tree for 33 posts.

and the code he/she/they/them quotes just lists all the fields in a table, not those without any values which is the requirement of the original post

"..initial post implies a single table in Access.."
No, only you imply

"..databases with the implication it is actually sql server.."
No, only you imply

"..the code he/she/they/them quotes just lists all the fields in a table.."
Exactly of wich code you are writing?

You assume or implied a little too many things that aren't implied
And all the objections you are highlighting are the consequence of the fact that you take some things for granted
And then you grumble because they are not as you assumed them
The logic would be, if one aspect of the question is not clear (And this may be that I didn't describe the problem well), to ask for explanations
Let's leave barking to dogs, not humans or programmers
 
Ok, this is accettable, with Ansi Sql is not possible
With Microsoft Sql Server did you think is possible?

Not an expert on SQL Server. However, the orientation of SQL and the principles of Interrogatory Logic used by SQL suggest that it might be extremely difficult for ANY version of SQL unless you allow for some VBA or other code that falls outside of "pure" SQL syntax. In essence, the way the question was asked is skirting the issues of the Goedel Completeness Theorem. In order for SQL to be correct as an interrogatory language (which means it always gives a definitive answer), it cannot be complete. Being not complete means - among other things - that it should not be able to make self-references or self-examination. Stated another way, the ability to see one's own metadata runs the risk of that old conundrum: "This statement is false." A self-referential statement can lead to such self-contradiction. Which is why SQL doesn't normally have that ability. Vendor extensions that allow SQL self-examination have to be limited because otherwise they would run into the perils of non-finite automata. (I.e. either infinite loops or indeterminate results leading to errors.)
 
You assume or implied a little too many things that aren't implied
And all the objections you are highlighting are the consequence of the fact that you take some things for granted
And then you grumble because they are not as you assumed them
The logic would be, if one aspect of the question is not clear (And this may be that I didn't describe the problem well), to ask for explanations
Let's leave barking to dogs, not humans or programmers
You post in a website called 'Access World Forums' with a url 'access-programmers.co.uk' on a forum board called 'Microsoft Access Discussion -> Queries' and then complain we might assume your question is about queries in MS Access!

'Effin' troll.

If you continue to play your games of pin the donkey you may soon find that no one bothers to answer any of your questions. :rolleyes:
 
You post in a website called 'Access World Forums' with a url 'access-programmers.co.uk' on a forum board called 'Microsoft Access Discussion -> Queries' and then complain we might assume your question is about queries in MS Access!

'Effin' troll.

If you continue to play your games of pin the donkey you may soon find that no one bothers to answer any of your questions. :rolleyes:

"..we might assume your question is about queries in MS Access.."
My question IS about Access queries

This 'Effin' trolls I don't quite understand what it means
I think it's an offense? If so, is it tolerated by the administrators of this forum?

"..play your games .."
I'm really not playing, I asked a question, and if anyone can answer I'll be grateful

If the forum users don't know what to answer, or don't want to help me, that's fine too
The only thing that's not good is that there's someone who thinks they can call others a troll
That's the only thing that's not good
But education and the ability to behave properly with other people is a quality not available to everyone
 
Last edited:
OK, guys... As a moderator, I have the right/duty to step in and ask politely for a bit of de-escalation.

Anyone who does not feel they need to participate in this discussion is not obligated to do so. We are ALL volunteers and have the right to pick-and-choose how we spend our forum time. Rather than allow this to develop into a "personalities" issue, anyone who is upset can just bow out gracefully. I request that if you no longer wish to participate in this question, that you just say "I have nothing else to contribute" and leave it at that. I believe @amorosik has detected that some folks are upset, so would not be surprised by such departure.
 
My question IS about Access queries
Access "speaks" generically Jet-SQL (SQL-89), no matter where data is stored. If you want to communicate directly with other DBMS, you would have to explicitly use their SQL dialect. But that was not asked.

If the forum users don't know what to answer
You got the answer, you just don't understand it. Whether you can't or don't want to, I don't know.

I recommend a little more humility and a little less of the over-confidence.
 
Anyone who does not feel they need to participate in this discussion is not obligated to do so. We are ALL volunteers and have the right to pick-and-choose how we spend our forum time. Rather than allow this to develop into a "personalities" issue, anyone who is upset can just bow out gracefully.
Doc, I'm less than a year and half since I joined and never doubted your judgment.
But it seems that everything has a first time.

You can see this strugle in every post the OP has started, yet your warning goes only to those who state they're going to drop out?
 
@KitaYama - my comment would also apply to the OP if he decides he's had enough of this thread. After all, he has struggled to get an answer as much as we have struggled to give one. But this struggle doesn't really matter. Though it may be causative in the little blow-up we experienced, it is not the issue that counts. Yes, this thread has been like undergoing exploratory surgery with limited anesthetic insofar as there may be a language barrier and there surely is an experience barrier. Yes, getting a clear picture of what is required has been difficult. However, "clarity of statement" is not a rule, it is merely a fervent hope.

The rule that was being violated is the requirement to treat other members with respect. When vulgarities are directed at another member, it is time to cool off, and that is exactly what I requested. If things cool down a bit, I don't need to impose a penalty. I would prefer to not have to do that.

You seem to think I should penalize the OP, but I think failure to communicate such that you can't get your question answered is its own form of punishment. Building a reputation for being difficult is another penalty of its own kind. It is also a self-correcting issue - with just a little bit of patience.
 
Access "speaks" generically Jet-SQL (SQL-89), no matter where data is stored. If you want to communicate directly with other DBMS, you would have to explicitly use their SQL dialect. But that was not asked.


You got the answer, you just don't understand it. Whether you can't or don't want to, I don't know.

I recommend a little more humility and a little less of the over-confidence.

"..But that was not asked.."
Access also allows you to send queries directly to the db server to which it is connected, and to read the returned results exactly like all other queries, there is no reason to treat them differently, if you re-read the initial request I never restricted the possibility only to "Access Jet-Sql (Sql89)" queries, and if I don't ask, why do you assume it's a given condition?

"..you just don't understand it.."
You're pointing to post #32 where you say it can't be done
Maybe you haven't read post #33 or #35 where I show you how it's possible to do it instead

"..I recommend a little more humility and.."
Thank you very much for the wish
Will you also send it to those who took the liberty of insulting me?
 
The application, which you didn't bother to try, can examine tables local to or linked to ANY Access FE. It doesn't matter what RDBMS houses the BE or even how many BE's the FE links to or whether they are mixed RDBMS' or just one. The app will work with Jet/ACE, SQL Server, Oracle, DB2, Sybase, Postgre, etc!!!!!!!!!! If your Access app can link to the RDBMS and work with it, then pick the FE from the dialog and that is ALL you need to do.

The output is a table with ONE row per table in the analyzed database that has ANY columns where all the rows are empty. So, if the BE has 100 tables and only two of them have any columns where any column has no value on any row, then the output will be 2 rows with as many columns (up to 20 - which you can easily expand with NO CODE CHANGES (OK, you have to change the number 20 to the new limit or remove the validation))

The only reason I bothered with creating this was because I thought it to be a useful utility but not the way anyone had presented it to date. Having to read through dozens of lines of spaced out text in the debug window was not a useful way to look at the output for anything more than a couple of tables. My altered solution can display results for as many tables as your app is linking to in a format that is concise and easy to understand and use.

You're welcome.

"..The application, which you didn't bother to try,.."
The application, which I took the trouble to test, can surely do everything you says
And i thank you very much for the help provided
But it doesn't answer the original question
The question is whether it is possible, by passing only the name of a table, with a single query to have returned fields that have never been used (which return null) on any row of data
This was the question and this remains
The problem of finding unused fields on a table has already been solved a few months ago
And therefore the routine is already available in my tools bag
What I wanted to understand was if it was possible to do all the work that is currently done with code with a single query
Where by 'query' I mean one of the queries that can be used with Access and therefore also the passthrough (it seems that lately it is necessary to specify this thing)

"..You're welcome..."
Thank you
 
My question IS about Access queries
This sentence is unmistakable. Access primarily uses Jet-SQL. This is not an assumed condition but a fact, like jumping in the water will get you wet.

The SQL optimizer (also in Jet/ACE) uses internal table statistics to determine execution plans for queries. So something like the counted contents in fields will already exist. However, access to it is not included in normal SQL (Data Manupulating Language). Point. The simple magic wand for all conceivable DBMS, as you imagine it, does not exist as a query, unless you create table statistics yourself as shown (including table definitions / data definition language).

You can believe and pray and hope for miracles. I've repeated myself often enough. Any additional word is a waste of time.
 
You're saying it's not possible to do something that I showed you how to do in post #35
Yes, I agree with you, I believe that every added word is useless
 
You're saying it's not possible to do something that I showed you how to do in post #35
Yes, I agree with you, I believe that every added word is useless

Your post #35 will work with SQL Server, I presume, because SQL Server exposes its metadata.

For a generic SQL statement you will not succeed with queries because if you stay generic, you will be forced to use ANSI SQL, which does not expose metadata. That requires specific knowledge of the vendor's method of storing metadata, and every one of them does it in a different way. It also requires a way to make indirect references in SQL, and again, not every version of SQL allows indirection. So this would be a case where one size does not fit all.

For an Access "native" back-end or for tables included in a front-end or monolithic DB, you will not succeed with pure SQL because while Access tables names CAN be identified, the interface for a single query will not transfer field names so easily to support a query on specific fields.

I will not insult you, amorosik, but I will say this: You have been persistent to the point that you have alienated some people. The reason for that alienation is that your repeated questions on the same topic imply that you know more than they do since you won't take NO for the answers they give you. Some databases simply won't do what you asked about. Many will not because of your initial question:

I need a query that returns, given the name of a table in the db, all the names of the fields that have never been filled in any row of the data present
Basically the fields I could also delete because at the moment they don't contain any information
How to make a unique query that return the field name as above?

A unique query probably cannot be written in most variants of SQL. This query cannot happen unless the vendor exposes the schema as tables accessible by queries. Not all vendors do that. You also gave us this statement:

As you surely know, there are methods that allow you to 'read' the names of the 'objects' contained in the db, whatever it is
Whether we are talking about Sql Server, Oracle, Db2, Postgresql, tiny SqLite or other

But then there was a key sentence:

get the name of the objects in response, if these objects were data tables, then the query will return the names of the tables, while if the objects were the names of the single fields of a table then a single query could return the field names of that table
What is written above is only a feature that you need to use to answer the initial question

The flaw in this statement is that NOT ALL VENDORS DO THIS! The ones that expose their metadata as tables might be able to do this. The ones that don't expose their metadata won't. Access metadata can be read, but the problem would then be to, in a single query or in a sub-query transfer table and field names to the scanning query that would do the actual "empty column" test given the table name you wanted to input. In your post #35, you did indeed show us something from SQL Server. That query cannot be run against the JET or ACE DB engines in Access itself because those structures don't exist in that format in Access.

In #41, you asked us: "Are you telling me you don't know how to run a passthrough query?" - so that means we ARE talking about a non-Access version of SQL where you can send statements to that server that cannot be run on Access SQL. In post #42, you named other SQL vendor products and said this:

But the question asked is a query on a generic db, then Sql Server will have its own system to read the fields of a table, Postgresql will have another system, Firebird will have its own system, this is not the important thing
The important thing is how to set up the query to get the names of the fields never used (which I think are the ones that return all null in all rows)

So that means you are talking about trying to find a generic query, not an Access or SQL Server query? I answered you directly in post #48 and then in post #51 gave you a reason based on Language Theory (related to SQL) why you couldn't do what you wanted in the general case.

You also said "Let's leave barking to dogs, not humans or programmers" in response to folks who had trouble following your leaps of focus. While that is less vulgar than other comments in this thread, it was also disrespectful. Just as I asked others to back down, I will also ask you to back down.

In summary, the answer to your original question plus the variations you have asked, is:

NO you cannot do that kind of work in a generic query or set of queries that would run on generic SQL. For the generic case, to do what you asked would violate linguistic rules associated with SQL and would violate Set Theory concepts as applied to SQL. The metadata you would need to examine belongs to a metadata set that is not an exposed part of the primary data set.

MAYBE you can build such a query when running under specific vendors. But even there, you cannot do it in a single query because of the need to breach the logic wall between ordinary data and metadata. I suspect you would need several layers of query to do that.
 
I liked the idea of this so I cleaned it up a little and made it easier to use.
Great piece of code Pat. I developed several Access DB's many years ago and upgraded same many times as customer needs changed. Always saying after I sorted out the bugs I'd go back and delete old versions of unnecessary tables and remove unused fields. Your application is fantastic. Thanks for sharing!
 

Users who are viewing this thread

Back
Top Bottom