HIDB1 has 13 GB mdf file size. with full recovery option and about 250 MB Log.I have a job that runs Once aweek. and Takes about 5 minutes.But Day after , Log file grows about 9 GB !!! . exactly after that job . (I traced it on .Trn back file)And then I Quickly shrink it. (I repeat it about 4 weeks)Why does this happen?----------------------------------------------------this our job steps :step1 : exec dbo.Admin_reindexstep2 : exec dbo.admin_updateStat----------------------------------------------------- Admin_Reindex USE [DB1]GO/****** Object: StoredProcedure [dbo].[Admin_reindex] Script Date: 1/30/2015 8:26:39 AM ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE PROCEDURE [dbo].[Admin_reindex]asif exists (select name from master.dbo.sysdevices where name = '#temptable')drop table #temptableelseSELECT 'alter index '+ quotename(i.name)+' on '+schema_Name(schema_id)+'.'+o.name+' rebuild' as d1 into #temptable FROM [sys].[indexes] as i,[sys].[objects] as o where i.object_id>45 and i.object_id=o.object_id and o.name not like 'queue_messages%' and o.name not like 'filestream_tomb%' and o.name not like 'sys%' and i.name <> 'NULL' and schema_Name(schema_id) not like 'sys%'declare @execStr varchar(256)declare DB_Cursor Cursor Forselect D1 from #temptable open DB_CursorFETCH NEXT FROM DB_Cursor into @execStrWHILE @@FETCH_STATUS = 0BEGIN BEGIN TRY EXECUTE (@execStr) END TRY BEGIN CATCH insert into Adm_ErrorIndexStat Values(@execStr, 'Index' , GETDATE()) END CATCH; --print @execStr FETCH NEXT FROM DB_Cursor into @execStrENDCLOSE DB_CursorDEALLOCATE DB_CursorGO--------------------------------------------------------------------- Admin_RebuildUSE [DB1]GO/****** Object: StoredProcedure [dbo].[Admin_UpdateStat] Script Date: 1/30/2015 8:27:23 AM ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE PROCEDURE [dbo].[Admin_UpdateStat]asif exists (select name from master.dbo.sysdevices where name = '#temptable2')drop table #temptable2elseSELECT 'UPDATE STATISTICS '+ schema_Name(schema_id)+'.'+o.name + ' '+quotename(i.name) as d1 into #temptable2 FROM [sys].[indexes] as i,[sys].[objects] as o where i.object_id>45 and i.object_id=o.object_id and o.name not like 'queue_messages%' and o.name not like 'filestream_tomb%' and o.name not like 'sys%' and i.name <> 'NULL' and schema_Name(schema_id) not like 'sys%'declare @execStr varchar(256)declare DB_Cursor Cursor Forselect D1 from #temptable2open DB_CursorFETCH NEXT FROM DB_Cursor into @execStrWHILE @@FETCH_STATUS = 0BEGIN BEGIN TRY EXECUTE (@execStr) END TRY BEGIN CATCH insert into Adm_ErrorIndexStat Values(@execStr, 'Statistics' , GETDATE()) END CATCH; --print @execStr FETCH NEXT FROM DB_Cursor into @execStrENDCLOSE DB_CursorDEALLOCATE DB_CursorGO
↧