Tuesday, November 21, 2017

Delete Excess Data in Table TaxDocumentJson from SQL command in Microsoft Dynamics AX

Delete Excess Data in Table TaxDocumentJson from SQL command in Microsoft Dynamics AX


Remove the excess data in TaxDocumentJson at in AX HQ. Please carry this out on a UAT environment. Once this is tested successfully, you can do the same steps on Production.
Run the following SQL query to remove excess data
DECLARE @Deleted_Rows INT;
SET @Deleted_Rows = 1;
WHILE (@Deleted_Rows > 0)
  BEGIN
   BEGIN TRANSACTION
   -- Delete some small number of rows at a time
     DELETE TOP (10) j from taxdocumentjson j
inner join TaxDocumentRow r on r.TAXDOCUMENTJSON = j.ID;
SET @Deleted_Rows = @@ROWCOUNT;   
   COMMIT TRANSACTION
   CHECKPOINT -- for simple recovery model
END
You can count the number of the records required to be cleaned via another session to understand the progress
Select count(*) from taxdocumentjson j inner join TaxDocumentRow r on r.TAXDOCUMENTJSON = j.ID;

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...