Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 COLUMN NAMES

Author  Topic 

smitha
Posting Yak Master

100 Posts

Posted - 2009-12-08 : 06:31:11
Hi,
How to display only the column names? I don't want data to be displayed.
Thanks in advance

Smitha

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2009-12-08 : 06:51:15
select top 0 * from table

or:

set rowcount 0
select * from table
Go to Top of Page

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-12-08 : 07:07:57
Or

SELECT * FROM <Table_Name> WHERE 1 = 2

-------------------------
R...
Go to Top of Page

smitha
Posting Yak Master

100 Posts

Posted - 2009-12-09 : 01:49:10
quote:
Originally posted by rajdaksha

Or

SELECT * FROM <Table_Name> WHERE 1 = 2

-------------------------
R...




I am not getting blank in the list.
Actually I want to update the column names of the table in the list box in my application. I have written code for this. but column names are not getting updated.

Smitha
Go to Top of Page

smitha
Posting Yak Master

100 Posts

Posted - 2009-12-09 : 01:51:07
quote:
Originally posted by RickD

select top 0 * from table

or:

set rowcount 0
select * from table



I tried both queries.
In the 1st query it is showing blank in the list box.
In the 2nd query it is showing the values of the 1st column.

Smitha
Go to Top of Page

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-12-09 : 02:13:39
Hi

I think u need this...

SELECT NAME FROM SYS.COLUMNS WHERE [OBJECT_ID] = OBJECT_ID('Your_Table_Name')

-------------------------
R...
Go to Top of Page

smitha
Posting Yak Master

100 Posts

Posted - 2009-12-09 : 02:38:30
Hi,
I wrote your code like this:

SELECT name
FROM sys.columns
WHERE (object_id = OBJECT_ID(' dbo.ELECTROLYSER1'))

But gave me no result

Smitha
Go to Top of Page

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-12-09 : 02:57:46
quote:
Originally posted by smitha

Hi,
I wrote your code like this:

SELECT name
FROM sys.columns
WHERE (object_id = OBJECT_ID(' dbo.ELECTROLYSER1'))

But gave me no result

Smitha




Try this...

SELECT name
FROM sys.columns
WHERE (object_id = OBJECT_ID('ELECTROLYSER1'))

-------------------------
R...
Go to Top of Page

smitha
Posting Yak Master

100 Posts

Posted - 2009-12-09 : 03:08:05
quote:
Originally posted by rajdaksha

quote:
Originally posted by smitha

Hi,
I wrote your code like this:

SELECT name
FROM sys.columns
WHERE (object_id = OBJECT_ID(' dbo.ELECTROLYSER1'))

But gave me no result

Smitha




Try this...

Thanks I got the answer

SELECT name
FROM sys.columns
WHERE (object_id = OBJECT_ID('ELECTROLYSER1'))

-------------------------
R...




Smitha
Go to Top of Page

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-12-09 : 03:11:24
quote:
Originally posted by smitha

quote:
Originally posted by rajdaksha

quote:
Originally posted by smitha

Hi,
I wrote your code like this:

SELECT name
FROM sys.columns
WHERE (object_id = OBJECT_ID(' dbo.ELECTROLYSER1'))

But gave me no result

Smitha




Try this...

Thanks I got the answer

SELECT name
FROM sys.columns
WHERE (object_id = OBJECT_ID('ELECTROLYSER1'))

-------------------------
R...




Smitha




Enjoy Madi

-------------------------
R...
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2009-12-09 : 06:32:13
This is a perfect example of someone not knowing how to ask the right question.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-01-06 : 08:40:27
quote:
Originally posted by RickD

select top 0 * from table

or:

set rowcount 0
select * from table


Set rowcount 0 will give you all rows

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-01-06 : 08:41:34
or

select column_name from information_schema.columns where table_name='ELECTROLYSER1'

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-06 : 09:44:35
quote:
Originally posted by madhivanan

or

select column_name from information_schema.columns where table_name='ELECTROLYSER1'

Madhivanan

Failing to plan is Planning to fail


this is my preffered method
Go to Top of Page
   

- Advertisement -