查询在指定的数据库中所有的表名和每个表的字段名及字段类型

时间:2022-03-01 13:45:17
select t.name as tablename,c.name as columnname,ty.name as typename,
c.max_length as typelength
from sys.columns c inner join sys.tables t on t.object_id=c.object_id
inner join sys.types ty on ty.system_type_id=c.system_type_id
order by t.name,c.column_id