菜鸟问题,请问如何用SQL语言列出当前数据库有什么表和每个表有多少列

samueler 2003-10-01 11:20:53
如题
...全文
45 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zjcxc 元老 2003-10-02
  • 打赏
  • 举报
回复
select 表名=name,列数=(select count(*) from syscolumns where id=a.id)
from sysobjects a where xtype='U'
txlicenhe 2003-10-02
  • 打赏
  • 举报
回复
select a.name 表名,count(b.id) 列数 from sysobjects a,syscolumns b where a.id=b.id and a.xtype='u'
group by a.name order by a.name

即可列出所有表名和所有表中的列数
samueler 2003-10-02
  • 打赏
  • 举报
回复
如果不知到有些什么表应该如何查出来?
sdhdy 2003-10-01
  • 打赏
  • 举报
回复
select a.name 表名,count(b.id) 列数 from sysobjects a,syscolumns b where a.id=b.id and a.xtype='u'
group by a.name order by a.name

34,875

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧