SQL 查询所有表名/指定表名、字段、类型、大小
1、所有表
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
2、指定表
select b.name as tablename,a.name as columnname,c.name as typename,a.max_length as typelength from sys.columns a inner join sys.tables b on b.object_id=a.object_id inner join sys.types c on c.system_type_id=a.system_type_id where b.name='表名' order by b.name,a.column_id
创建时间:2021.05.11 更新时间:2021.06.07