• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 815
  • Last Modified:

SQL query select statement to get table headers only

Hi,

I am looking for a sql query select statement to get table headers only.  
Any idea?

Thank you,
RD11
0
RD11
Asked:
RD11
3 Solutions
 
knightEknightCommented:
what do you mean by headers?  do you mean the column names?

select *
from myTable
where 1=0
0
 
LowfatspreadCommented:
select * into #temp from yourtable
where 0=1
select * from #temp



or you could query the information_schema.columns view for the column names...

select column_name from information_schema.columns
where table_name='xxxxx'
order by ordinal_number
0
 
RD11Author Commented:
I just want to get the column headers in a table.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
markterryCommented:
Select column_Name  from information_Schema.columns where table_name = 'TableName'
0
 
markterryCommented:
Just replace the last 'tablename' with a real table name
0
 
RD11Author Commented:
Does this work in MS Access, I could not run it.  I got an error message that it could not find the schema file.
0
 
markterryCommented:
Oh, sorry, you put a zone of MS SQL.


Get Access Field names
Sub FieldNames()
    Dim Rst As Recordset
    Dim f As Field
    
    Set Rst = CurrentDb.OpenRecordset("TableName")
    
    For Each f In Rst.Fields
        MsgBox (f.name)
    Next
    Rst.Close
End Sub

Open in new window

0
 
RD11Author Commented:
All G:):)D Thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now