473,549 Members | 2,862 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sql query for displaying only column names

I would like to know the SQL statement for displaying only the column
names of a particular table. For eg. if I have a table by the name
DETAILS and it has three columns FIRST_NAME, LAST_NAME and
DT_OF_BIRTH, using what SQL statement can I display only the column
names and not their content ?

May 24 '07 #1
4 83563
On May 24, 8:50 am, mailsu...@gmail .com wrote:
I would like to know the SQL statement for displaying only the column
names of a particular table. For eg. if I have a table by the name
DETAILS and it has three columns FIRST_NAME, LAST_NAME and
DT_OF_BIRTH, using what SQL statement can I display only the column
names and not their content ?
SELECT TABNAME,COLNAME from SYSCAT.COLUMNS where TABNAME='DETAIL S'

May 24 '07 #2
On May 24, 2:19 pm, situ <SRIDHAR...@RED IFFMAIL.COMwrot e:
On May 24, 8:50 am, mailsu...@gmail .com wrote:
I would like to know the SQL statement for displaying only the column
names of a particular table. For eg. if I have a table by the name
DETAILS and it has three columns FIRST_NAME, LAST_NAME and
DT_OF_BIRTH, using what SQL statement can I display only the column
names and not their content ?

SELECT TABNAME,COLNAME from SYSCAT.COLUMNS where TABNAME='DETAIL S'
Thanks !

May 24 '07 #3
ma*******@gmail .com wrote:
On May 24, 2:19 pm, situ <SRIDHAR...@RED IFFMAIL.COMwrot e:
>On May 24, 8:50 am, mailsu...@gmail .com wrote:
I would like to know the SQL statement for displaying only the column
names of a particular table. For eg. if I have a table by the name
DETAILS and it has three columns FIRST_NAME, LAST_NAME and
DT_OF_BIRTH, using what SQL statement can I display only the column
names and not their content ?

SELECT TABNAME,COLNAME from SYSCAT.COLUMNS where TABNAME='DETAIL S'
In addition to situs answer, I you are running your query from a host
language such as java, a common trick is to select from the table with a
predicate that is always false, and then grab the metadata from the
resultset. I.e.

select * from DETAILS where 1=0

I'm not saying that this is better, only that it is another possability
/Lennart

May 24 '07 #4
Ian
Lennart wrote:
ma*******@gmail .com wrote:
>On May 24, 2:19 pm, situ <SRIDHAR...@RED IFFMAIL.COMwrot e:
>>On May 24, 8:50 am, mailsu...@gmail .com wrote:

I would like to know the SQL statement for displaying only the column
names of a particular table. For eg. if I have a table by the name
DETAILS and it has three columns FIRST_NAME, LAST_NAME and
DT_OF_BIRTH, using what SQL statement can I display only the column
names and not their content ?

SELECT TABNAME,COLNAME from SYSCAT.COLUMNS where TABNAME='DETAIL S'

In addition to situs answer, I you are running your query from a host
language such as java, a common trick is to select from the table with a
predicate that is always false, and then grab the metadata from the
resultset. I.e.

select * from DETAILS where 1=0

I'm not saying that this is better, only that it is another possability
Or how about 'DESCRIBE TABLE DETAILS'

May 24 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3908
by: Joe Gazda | last post by:
I'm a relative newbie to PHP, but have been able to put together some PHP code to generate a CSV/XLS file from a Query result. Now, I would like to include custom column names instead of the MySQL column table names. I know that there are codes to generate tabs and carriage returns, but can't find anything about including "commas" in a string...
1
12192
by: noor | last post by:
Hi I have been working since 2 days to device a method to export sql table into csv format. I have tried using bcp with format option to keep the column names but I'm unable to transfer the file with column names. and also I'm having problems on columns having decimal data. Can any one suggest me how to automate data transfer(by using SP) and...
2
1707
by: Piotr Kurpiel | last post by:
Hello, I am using MS Access 2003 with VBScript. I have quite strange column names which are: 1,2,3,4,etc... Data Types of the columns are Yes/No and formats True/False. The first thing I want to do is count rows with True in column 1, then column 2, etc. My query is: "SELECT count(*) AS ile FROM profiles WHERE 1 = True" It doesn't work. I...
3
10063
by: Harry Whitehouse | last post by:
How might one go about this. I know how to select data records, but suppose I wanted to fill a datagrid with the column names in a specified table? How would I start? TIA Harry
7
21034
by: | last post by:
Need help finding simple way to retrieve a fields (or columns) collection from a Dataset without filling it first.
2
1311
by: craigkenisston | last post by:
Im trying to make an application using all the out of the box stuff for data displaying. Using (or trying to) use a BLL and DLL. Now, in my database, the tables and columns have names like these: Table TBL01_PRODUCT Col PRD_CODE Col PRD_NAME etc, etc What I mean, they are cryptic, not friendly names.
1
3400
by: christianlott1 | last post by:
I want to provide users with an interface to create a custom merge (all in Access, not Word). User will put in a set of brackets ("<>") in a memo field and when they click the merge button it will grab the fields listed in a tabular subform and merge it with their memo text. I was able to retrieve the code to list the column names of a...
1
2221
by: bugs2bugs | last post by:
Hello, We're using SQL Server 2000 and Query Manager (not Visual Studio). When your query results are returned, the column names are displayed at the top, but this information is NOT available for cut/paste to Excel. One of the workarounds we thought of was to return the column names within the query itself, and thought there was perhaps an...
1
3676
by: ncsthbell | last post by:
Once again... I am supporting another Access database that I did not build. The previous 'owner' of this built the tables with spaces in the table names as well as the column names. I am having a difficult time getting the select statement to work. I am getting a run-time error 2342. "A RunSql action requires and arguement consisting fo an SQL...
0
7715
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7956
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7808
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5087
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1935
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1057
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.