sqlServer 数据库纵横表相互转化 一.纵表转横表: 1.纵表: 2.横表: 3. 代码: select Name as '姓名', end) as '语文', end) as '数学', end) as '英语' from Score group by Name 二.横表转纵表: 1.横表: 2.竖表: 3.代码: select * from( select Name as '姓名','语文' as '语文',Chinise as '分数' from Score1 union all…
查询所有表以及记录数: 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 1.查询数据库中的所有数据库名: SELECT Name FROM Master..SysDatabases ORDER BY Name 2.查询某个数据库中所有的表名: SELECT…
SELECT DISTINCT TOP 100 PERCENT isnull(p.name,'') AS 父对象, o.xtype, CASE o.xtype WHEN 'C' THEN 'CHECK 约束' WHEN 'D' THEN '默认值或DEFAULT约束' WHEN 'F' THEN 'FOREIGNKEY约束' WHEN 'L' THEN '日志' WHEN 'FN' THEN '标量函数' WHEN 'IF' THEN '内嵌表函数…