Installation and deployment
Version 7.x > Installation and deployment > Trimming staging tasks View modes: 
User avatar
Certified Developer 9
Certified Developer 9
pmcweb - 3/5/2014 8:39:54 AM
   
Trimming staging tasks
Hi,

Not sure this is the right place to post this or not, as with the new design Forum is obsolete?

Anyway, this is more for anyone else like me that wanted to trim the staging tasks tables to reduce database backup, you can use this code below:


BEGIN TRANSACTION
BEGIN TRY


ALTER TABLE [dbo].[Staging_SyncLog] DROP CONSTRAINT [FK_Staging_SyncLog_SyncLogTaskID_Staging_Task]
ALTER TABLE [dbo].[Staging_Synchronization] DROP CONSTRAINT [FK_Staging_Synchronization_SynchronizationTaskID_Staging_Task]


truncate table staging_synchronization
truncate table staging_synclog
truncate table staging_task

ALTER TABLE [dbo].[Staging_SyncLog] WITH CHECK ADD CONSTRAINT [FK_Staging_SyncLog_SyncLogTaskID_Staging_Task] FOREIGN KEY([SyncLogTaskID])
REFERENCES [dbo].[Staging_Task] ([TaskID])
ALTER TABLE [dbo].[Staging_SyncLog] CHECK CONSTRAINT [FK_Staging_SyncLog_SyncLogTaskID_Staging_Task]

ALTER TABLE [dbo].[Staging_Synchronization] WITH CHECK ADD CONSTRAINT [FK_Staging_Synchronization_SynchronizationTaskID_Staging_Task] FOREIGN KEY([SynchronizationTaskID])
REFERENCES [dbo].[Staging_Task] ([TaskID])
ALTER TABLE [dbo].[Staging_Synchronization] CHECK CONSTRAINT [FK_Staging_Synchronization_SynchronizationTaskID_Staging_Task]

END TRY
BEGIN CATCH

IF @@TRANCOUNT > 0
ROLLBACK TRANSACTION;

DECLARE @ErrorMessage NVARCHAR(4000), @ErrorSeverity INT, @ErrorState INT;

SELECT @ErrorMessage = ERROR_MESSAGE(),
@ErrorSeverity = ERROR_SEVERITY(),
@ErrorState = ERROR_STATE();

RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState);
END CATCH


IF @@TRANCOUNT > 0
COMMIT TRANSACTION;


Please note this is v7's DB schema, so it might not work on other versions.

Hope this helps,
P.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 3/6/2014 1:51:57 AM
   
RE:Trimming staging tasks
Hi,

Thank you for sharing this. The forums will be closed soon since the new Question & Answers section is replacing this forum.

Best regards,
Juraj Ondrus