针对SQL Server数据库,SQL语句应该这样写:
select s.name as 表名,c.name as 字段名,t.name as 字段类型,t.length as 长度
from sysobjects s
inner join syscolumns c on s.id = c.id
inner join systypes t on c.usertype = t.usertype
where s.xtype = 'U' and s.name = :yourTableName
表名作为参数,建立一个查询数据集,直接连到TDBGridEh上就可以了,随着参数的变化和数据集的重新打开,你就实现了罗列不同表结构的效果