How to delete all transactions, and keep all the settings intact?

Hi to all

I need to delete all transactions within a company in AX2009, but keep the settings, parameters, codes set up, code groups eg VAT groups, etc . Can someone tell me how to go about doing this? Also, is it possible to transfer settings, parameters, etc to a different company? And how can I tell which tables have data stored within them currently? I have tried to do this, but every time I try to delete a table, I get messages saying that records are linked to other tables, and I cant delete some of those other records, etc etc. Plus Im not sure if I should even be doing this, is it a bad idea?

Thanks

Naz

  1. To delete transactions you can run the class SysDatabaseTransDelete

  2. Once clear from company accounts you could run a duplicate to create a new company. You could also create an all definition group export to get the data out.

  3. Tables with data can be seen by selecting Tools - Development Tools - Number of records. Obviously a parameter table has 1.

The answer to the “should you be doing this” question is no, because of the questions you have had to ask [:D] Ask someone internally what the procedures and guidelines are for this.

Hi, and thanks for the reply! :slight_smile:

Just to clarify, I am not actually deleting any real data - we are in the beginning stages of moving ourselves over to AX09, Im here to do that job of migration! So its not a problem, the only transactions I am deleting are test transactions I have been putting through which wont obviously be needed once we go live.

Our install company isnt much good sadly, they never have any answers to any of my questions…

What is an all definition group export, what does it do? And how do I do it?

Thanks for the help!

Naz

Also, how do I run SysDatabasetransDelete? I have right clicked that class and selected Compile, but it doesnt seem to do anything? All I get is a Compiler Output message, saying that there are no errors, warnings, Best practice Deviations, tasks. Is this correct?

Thanks

Naz

Aha! That worked, transactions are deleted!! Thank you sooo much!

Another related question - I want to delete all addresses, supliers, customers, Global Address Book - is there an easy way to do this, and get rid of all links to these addresses in all the AX09 tables? I have deleted the few customers and suppliers I set up, but their details seem to be in other tables, eg the Address table - is there an easy way to get rid of all of that too?

Thanks

Naz

I would suggest if your “partner” is not giving you answers to questions at this stage of the implementation then you get a new partner!

There is no quick way to delete the addresses, you need to go into each table. If you had a developer they could write you a script to go through all of the tables, but I am guessing that is not an option for you.

The definition groups are under periodic in administration. Create a standard one and it will list every table and field for you and selecting export just exports all the data.

I am not an AX consultant ,but for SQL script from a developer we can help you out:

The SQL script to delete data in a table is:

Delete from or truncate table

If you want, I can also paste there a piece of SQL code which shows you for each table how many rows are present and which not. I think you might to reset your ‘number ranges’ for the documents. Like CUST001 is for customer 1, CUST002 is for customer 2. I think you can manually reset these sequences through customization.

J.

This is a stored procedure you can run in SQL query of Visual Studio Management Studio. It will return all the tables in AX and tell you how many records, how much size etc. You can use it so see where you need to clean up tables. You can also code to output the first 10 lines of each table so that you can see very fast where data is remaining.

After you have created the sp you can run it with EXEC [dbo].[V4AbBaytGetTableSize] or by doing a right click on the sp.

==

IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N’[dbo].[V4AbBaytGetTableSize]’) AND type in (N’P’, N’PC’))

DROP PROCEDURE [dbo].[V4AbBaytGetTableSize]

GO

/*

THIS CODE IS TAILOR MADE; DO NOT CHANGE!

DATA EXCHANGE WITH NAVISION BACK OFFICE AND V4A STORE

INITIAL VERSION: 20070218 JO V4A

CHANGE HISTORY:

20070320_01 JO change RFC2

*/

CREATE PROCEDURE [dbo].[V4AbBaytGetTableSize]

(

@TableNames NVARCHAR(255) = NULL

)

AS

BEGIN

SET NOCOUNT ON

CREATE TABLE #TBLSize

(Tblname varchar(255),

TblRows int,

TblReserved varchar(80),

TblData varchar(80),

TblIndex_Size varchar(80),

TblUnused varchar(80))

DECLARE @DBname varchar(255)

DECLARE @tablename varchar(255)

SELECT @DBname = DB_NAME(DB_ID())

PRINT 'User Table size Report for (Server / Database): ’ + @@ServerName + ’ / ’ + @DBName

PRINT ‘’

PRINT ‘By Size Descending’

DECLARE TblName_cursor CURSOR FOR

SELECT [NAME]

FROM sysobjects

WHERE xType = ‘U’

AND

(

@TableNames IS NULL

OR

(@TableNames IS NOT NULL AND [NAME] LIKE ‘’ + @TableNames + ‘’)

)

OPEN TblName_cursor

FETCH NEXT FROM TblName_cursor

INTO @tablename

WHILE @@FETCH_STATUS = 0

BEGIN

INSERT INTO #tblSize ( Tblname, TblRows, TblReserved, TblData, TblIndex_Size, TblUnused)

EXEC Sp_SpaceUsed @tablename

– Get the next author.

FETCH NEXT FROM TblName_cursor

INTO @tablename

END

CLOSE TblName_cursor

DEALLOCATE TblName_cursor

/*

SELECT CAST(Tblname as Varchar(255)) ‘Table’,

CAST(TblRows as Varchar(14)) ‘Row Count’,

CAST(LEFT(TblReserved, CHARINDEX(’ KB’, TblReserved)) as int) ‘Total Space (KB)’,

CAST(TblData as Varchar(14)) ‘Data Space’,

CAST(TblIndex_Size as Varchar(14)) ‘Index Space’,

CAST(TblUnused as Varchar(14)) ‘Unused Space’

FROM #tblSize

Order by ‘Total Space (KB)’ Desc

*/

PRINT ‘’

PRINT ‘By Table Name Alphabetical’

SELECT CAST(REPLACE(Tblname, N’V4A_DNN_’, N’’) as Varchar(255)) ‘Table’,

CAST(TblRows as INT) ‘Row Count’,

CAST(LEFT(TblReserved, CHARINDEX(’ KB’, TblReserved)) as int) ‘Total Space (KB)’,

CAST(TblData as Varchar(14)) ‘Data Space’,

CAST(TblIndex_Size as Varchar(14)) ‘Index Space’,

CAST(TblUnused as Varchar(14)) ‘Unused Space’

FROM #tblSize

Order by ‘Total Space (KB)’ Desc – Order by ‘Table’

DROP TABLE #TblSize

END

Thanks you very much for this solution…

Regards,

Janak Talekar