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 2005 Forums
 SQL Server Administration (2005)
 Query Table and its column details

Author  Topic 

Dinky
Starting Member

37 Posts

Posted - 2008-04-23 : 12:08:02
How to query Table and its column details

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-04-23 : 12:13:32
Select * from information_schema.columns where table_name = 'foo'

or

sp_help 'foo'

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2008-04-25 : 04:46:06
in 2005, it is recommended to use sys views...add as many column names you want to see

select c.name as column_name,t.name as data_type,c.max_length,c.precision,c.scale,c.collation_name
from sys.columns c
join sys.types t on c.user_type_id=t.user_type_id
where object_id=object_id('tablename')


--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -