首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

一条简单的SQL大家进来看下哦。解决思路

2012-04-24 
一条简单的SQL大家进来看下哦。。select count(name) tablenum from bkysbase.dbo.sysobjects where type

一条简单的SQL大家进来看下哦。。
select count(name) tablenum from bkysbase.dbo.sysobjects where type ='U' 查表的

select count(name) tablenum from bkysbase.dbo.sysobjects where type ='V' 查视图的

我想把这两条sql合成一个 显示结果
tablen tablev
  500 20

还有就是我的服务器上有多个数据库,查询时候很慢,很慢,这个可以优化下吗?

[解决办法]

SQL code
select sum(case type when 'U' then 1 else 0 end) as tablen,  --,号       sum(case type when 'V' then 1 else 0 end) as tablevfrom bkysbase.dbo.sysobjects
[解决办法]
SQL code
select sum(case type when 'U' then 1 else 0 end) as tablen,       sum(case type when 'V' then 1 else 0 end) as tablevfrom sysobjectstablen    tablev131    362本机测试结果 

热点排行