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.