开发学院数据库MSSQL Server Sql Server 性能分析2 –查看数据库的大小以及数据... 阅读

Sql Server 性能分析2 –查看数据库的大小以及数据库表的大小(Linked Server)

 2009-09-05 00:00:00 来源:WEB开发网   
核心提示: ---Linked Server 获取远端数据库表的大小Create procedure [dbo].[Proc_DBA_MES_Table_Size]asDeclare @tb_name varchar(50)Declare @tb_list table( tb_name varchar(50

---Linked Server 获取远端数据库表的大小----

Create procedure [dbo].[Proc_DBA_MES_Table_Size]
as
Declare @tb_name varchar(50)
Declare @tb_list table
(
    tb_name varchar(50)
)

declare @tb_size table
(
    name      varchar(50),
    rows      varchar(50),
    Reserved   varchar(50),
    Data      varchar(50),
    Index_Size varchar(50),
    Unused     varchar(50)
)

declare cur_tb_list cursor for
    select name
from dbo.sysobjects
where objectproperty(id, N'istable') = 1
and name not like N'#%%'
order by name


open cur_tb_list
     fetch Next from cur_tb_list
           into @tb_name
   
     while @@fetch_status=0
         begin
       if exists (select * from dbo.sysobjects
                  where id = object_id(@tb_name)
                  and objectproperty(id, N'isusertable')=1)

           insert into @tb_size exec Srv_MES.InsiteProdDG.dbo.sp_spaceused @tb_name
   
       fetch Next from cur_tb_list
              into @tb_name
        end


insert into TB_DBA_Database_Table_Size
select convert(varchar(20),getdate(),120) as date_time,*
from @tb_size

close cur_tb_list
deallocate cur_tb_list

上一页  1 2 3 

Tags:Sql Server 性能分析

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接