Friday, August 21, 2015

Delete company in AX2012 using SQL

Sometimes we are not able to delete company from AX due to existing transactions then SQL comes to the rescue and does the job beautifully.

There is a Stored Procedure in "master" database named "sp_MSforeachtable". Use the below commands:


This will delete all the transactions from all the tables related to that particular company:


EXEC sp_MSforeachtable 'delete from ? where ?.DataAreaID = "CEU"'


This will delete the company name from the company list in AX:


DELETE FROM DATAAREA WHERE DATAAREA.ID 'CEU'

No comments:

Post a Comment