To limit the amount of time it takes to check row count on all sharepoint fulltext catalogs i started to develop some code for automating this. Unfortunately we had the power outage when i where done so had to rewrite the code. Now I have doen that but i cut some corners so it is not the nicest looking code but it does the job. It lists all databases with a fulltext catalog and gives the number of items in the catalog.
set nocount on
use master
create table mytemp
(FT_ID varchar(500),
FT_NAME varchar(500),
FT_PATH varchar(500),
status varchar(500),
nroftables varchar(500))
create table mytemp2
(db_names varchar(500),
FT_NAME varchar(500),
status varchar(500),
nroftables varchar(500),
counts int,
UniqueKeyCount bigint,
IndexSize int)
go
sp_msforeachdb ' use [?];
if (select DATABASEPROPERTY(DB_NAME(), N''IsFullTextEnabled'')) > 0
begin
insert into master..mytemp exec sp_help_fulltext_catalogs declare @tmp varchar(255);
declare @1 varchar(255)
declare @2 int
declare @3 int
declare @4 int
declare @5 bigint
declare @6 int
select @1 = ft_name,@3=status,@4=nroftables from master..mytemp
truncate table master..mytemp
SELECT @2= fulltextcatalogproperty(@1 , ''ItemCount'')
SELECT @5= fulltextcatalogproperty(@1 , ''UniqueKeyCount'')
SELECT @6= fulltextcatalogproperty(@1 , ''IndexSize'')
insert into master.dbo.mytemp2 (db_names,ft_name,counts,status,nroftables,UniqueKeyCount,IndexSize) select db_name(db_id()),@1,@2,@3,@4,@5,@6
end;'
go
delete from mytemp2 where ft_name is null
select sum(UniqueKeyCount) as 'Total number of UniqueKeyCount'
from mytemp2
select sum(counts) as 'Total number of rows'
from mytemp2
select db_names,ft_name, case status
when 0 then 'Idle'
when 1 then 'Full population in progress'
when 2 then 'Paused'
when 3 then 'Throttled'
when 4 then 'Recovering'
when 5 then 'Shutdown'
when 6 then 'Incremental population in progress'
when 7 then 'Building index'
when 8 then 'Disk is full. Paused'
when 9 then 'Change tracking'
else 'UNKNOWN Status'
end
,nroftables,counts,UniqueKeyCount,IndexSize as 'IndexSize in Mb'
from mytemp2 order by db_names
drop table mytemp
drop table mytemp2
No comments:
Post a Comment