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)
 Need help to query Column names, Data Type, and Le

Author  Topic 

ezmethod
Starting Member

2 Posts

Posted - 2008-09-19 : 12:00:38
Greetings everyone,

I need help constructing a query on sql 2005, which will allow me to list all column names, data types, and the lengths for each column within a single table, and the same query to list the same requirements for all tables in the database.

Any help will be greatly appreciated.

Regards,

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-09-19 : 12:40:09
Are you aware of system functions like SP_HELP:
exec sp_help '<yourTableName>'

What do you mean by "requirements for all tables"?

Be One with the Optimizer
TG
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-19 : 12:52:05
[code]SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='YourTableName'

for getting this for all tables use

EXEC sp_Msforeachtable 'SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME=''?'''[/code]
Go to Top of Page

ezmethod
Starting Member

2 Posts

Posted - 2008-09-19 : 13:10:28
You people rock

Thanks TG for guiding me on the SP_HELP feature.

Thanks Visakh16 for providing me with the exact queries I was looking for.

Best Regards,
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-19 : 13:11:38
quote:
Originally posted by ezmethod

You people rock

Thanks TG for guiding me on the SP_HELP feature.

Thanks Visakh16 for providing me with the exact queries I was looking for.

Best Regards,


welcome
Go to Top of Page
   

- Advertisement -