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
 Transact-SQL (2005)
 Help with System Query

Author  Topic 

qman
Constraint Violating Yak Guru

442 Posts

Posted - 2008-10-17 : 11:04:07
Can someone help me out with the following request?
How can I display table information (columns, data type, size, object name, etc....) via SQL Query? Basically, I want to create a query that displays what a certain table is made up of.

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-10-17 : 11:05:42
sp_help 'tablename'
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-17 : 11:06:32
SELECT c.COLUMN_NAME,c.DATA_TYPE,c.TABLE_NAME,..
FROM INFORMATION_SCHEMA.COLUMNS c
JOIN INFORMATION_SCHEMA.TABLES t
ON t.TABLE_NAME=c.TABLE_NAME
WHERE t.TABLE_TYPE='BASE TABLE'
Go to Top of Page

qman
Constraint Violating Yak Guru

442 Posts

Posted - 2008-10-17 : 11:08:55
Fantastic, thanks to both of you!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-17 : 11:09:55
quote:
Originally posted by qman

Fantastic, thanks to both of you!


welcome
Go to Top of Page
   

- Advertisement -