how to get column names given table name through sql query

how to get column names given table name through sql query

Post by Giridha » Wed, 16 Jun 1999 04:00:00



how to get  column names given table name through sql query ?

thanks in advance

 
 
 

how to get column names given table name through sql query

Post by Louis Casto » Wed, 16 Jun 1999 04:00:00


In SQL Server 6.5, you have the following options:
- For full table description, sp_help <table>
- Otherwise, for column name info only:
select sc.name
from sysobjects so, syscolumns sc
where so.name = "<table>"
and so.type = 'u'
and sc.id = so.id



Quote:> how to get  column names given table name through sql query ?

> thanks in advance

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

 
 
 

how to get column names given table name through sql query

Post by Wayne Snyde » Wed, 16 Jun 1999 04:00:00


In sql 7.0 try
select column_name from information_Schema.columns
where table_name = 'titles'
in sql 6.5 try
select name from syscolumns where id = object_id('titles')

HTH
--
Wayne Snyder MCT,MCSE, Sql Server MVP
IKON Technology Services, C*te, NC Education
(Please respond to newsgroup unless otherwise requested.)

 
 
 

how to get column names given table name through sql query

Post by Max Akba » Wed, 16 Jun 1999 04:00:00


use pubs
go
-- use this to get id # for the table


-- use this to get columns

Good luck,
-Max


Quote:> how to get  column names given table name through sql query ?

> thanks in advance