查询表名为History的所有列名 1 select name from syscolumns where id=object_id('History') 查询表名为History的所有列名个数 1 select count(name) from syscolumns where id=object_id('History') 或者 1 2 3 select count(syscolumns.name) from syscolumns ,sysobjects where sy…
查看所有表对应的数据量 SELECT a.name AS 表名, MAX(b.rows) AS 记录条数 FROM sys.sysobjects AS a INNER JOIN sys.sysindexes AS b ON a.id = b.id WHERE (a.xtype = 'u') GROUP BY a.name ORDER BY 记录条数 DESC 查看数据库的总数据量 SELECT SUM(记录条数) AS 总记录数 ) a.name AS 表名, MAX(b.rows) AS 记录…
T-sql 显示表结构和字段信息的sql语句: exec sp_help tablename; ~~使用存储过程 sp_help 显示数据库包含哪些表的sql语句: use yourDBname;select name from sysobjects where xtype='u'; ~~使用系统表 sysobjects 在当前数据库中查询其他数据库的表use shaowu2_2013;select * from ac where acid not in(select acid from sh…
select a.name as 表名,max(b.rows) as 记录条数 from sysobjects a ,sysindexes b where a.id=b.id and a.xtype='u' group by a.name order by max(b.rows) desc 当如果使用子查询对上面语句做求和方法时会报下面错误: 除非另外还指定了 TOP 或 FOR XML,否则,ORDER BY 子句在视图.内联函数.派生表.子查询和公用表表达式中无效. 只要我们在嵌套子查询视图…