Sql Server 性能分析2 –查看数据库的大小以及数据库表的大小(Linked Server)
2009-09-05 00:00:00 来源:WEB开发网---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
更多精彩
赞助商链接