22,209
社区成员
发帖
与我相关
我的任务
分享
--某一个表的列数
select count(*) from syscolumns where id =(select id from sysobjects where name='table1' and xtype='u')
--数据库所有表的列数
select count(*) from syscolumns where id in(select id from sysobjects where xtype='u')
select count(*) from syscolumns
select a.name, 字段数=COUNT(*)
from sysobjects a inner join syscolumns b
on a.id = b.id
where a.type='U'
group by a.id, a.name
select count(*) from sys.columns a inner join sys.objects b on a.object_id=b.object_id where b.type='U'