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本机测试结果