SQLUSA

Microsoft SQL Server 2000 Best Practices

How to list the columns in all of the tables?

 

The following query lists all the tables with columns and datatypes:

select TableName=substring(table_name, 1, 30),
ColumnName=substring(column_name, 1, 30),
DataType=data_type
from information_schema.columns c
join sysobjects o
on c.table_name = o.name
where o.xtype = 'U' and o.status > 0
order by TableName,ordinal_position

 

The World Leader in SQL Server Training
 
SQLUSA.com Home Page