SQL with no headers

S

Seth

How do you use a WHERE statement if a table has no
headers?

i.e., say there is a table called "EMPLOYEES"...I know
that the first column is FirstName and the second column
is LastName, but these are not headers...so the recordset
simply starts with the first name in the range.

Is it possible to use a WHERE criteria with no headers in
this case? I don't know how to identify the fields when
there are no headers.

Thanks,

Seth
 
P

Patrick Molloy

If your data is in a recordset and that is an extract
from a SQL database, then there are 'headers, ie column
names. One cannot create a table in any database without
column names.

If your data is in a recordset called RST then you can
get the 'headers' with a simple for.next loop:-

WITH RST
For i = 0 to .Fields.Count - 1
Cells(1,i+1).Value = .Fields(i).Name
Next
END WITH
Range("A2").CopyFromRecordset RST

HTH

Patrick Molloy
Microsoft Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top