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
 Transact-SQL (2000)
 Retrieving column names

Author  Topic 

rohans
Posting Yak Master

194 Posts

Posted - 2004-04-13 : 17:01:43
2.) How may I get a count on the column names in a table and
1.) The name of all the columns in the table

All help appreciated.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-04-13 : 17:05:02
1) SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'TableNameGoesHere'

2) SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'TableNameGoesHere'
ORDER BY ORDINAL_POSITION

Tara
Go to Top of Page

rohans
Posting Yak Master

194 Posts

Posted - 2004-04-13 : 17:10:05
Thanks much T

All help appreciated.
Go to Top of Page

rohans
Posting Yak Master

194 Posts

Posted - 2004-04-13 : 17:16:06
One problem still. It doesn''t work for sysobjects which is what I really want it for.

All help appreciated.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-04-13 : 17:17:13
sp_help 'sysobjects'

Tara
Go to Top of Page
   

- Advertisement -