Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 800
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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