Query a table w/o using column names?`

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've got an Access app that links to several user-created spreadsheets and does SQL summation, etc. Because of the nature of this appication (and the fact that my user's don't have any standards!), the names of the columns themselves can vary. Their absolute position does not change. So for instance, the first column in the linked sheet might be called [PERCENT GOAL] for one person, [PCT GOAL] for another person, and [% GOAL] for still another.

I can safely assume that regardless of what it's called, that first column is going to contain the value that I want. I've actually written a VBA function that, if given a table name and a column position, will return the column name. I use it to dynamically build SQL statements, and from a purely functional standpoint, it works. However, it's damn slow in running

Is there something native in SQL that I can put in a select statement that would represent "The First Column" or "The Seventh Column", regardless of what the columns are named?
 
Not in Access SQL, AFAIK.

You can do ORDER BY 1, which sorts by the first column, though. I know...
that doesn't help you.


--
HTH,

Steve Clark, Access MVP
FMS, Inc.
Professional Solutions Group
http://www.FMSInc.com
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Is your Access database too slow?
Are you ready to upgrade to SQL Server?
Contact us for optimization and/or upsizing!
http://www.FMSInc.com/consulting
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

MDW said:
I've got an Access app that links to several user-created spreadsheets and
does SQL summation, etc. Because of the nature of this appication (and the
fact that my user's don't have any standards!), the names of the columns
themselves can vary. Their absolute position does not change. So for
instance, the first column in the linked sheet might be called [PERCENT
GOAL] for one person, [PCT GOAL] for another person, and [% GOAL] for still
another.
I can safely assume that regardless of what it's called, that first column
is going to contain the value that I want. I've actually written a VBA
function that, if given a table name and a column position, will return the
column name. I use it to dynamically build SQL statements, and from a
purely functional standpoint, it works. However, it's damn slow in running.
Is there something native in SQL that I can put in a select statement that
would represent "The First Column" or "The Seventh Column", regardless of
what the columns are named?
 
I didn't think so.

However, I was able to get some help that greatly improved the efficiency of that function, so that works for me.
 
Back
Top