Discussion:
Purging table using X++
(too old to reply)
portect
2008-07-17 03:25:00 UTC
Permalink
Hi,

I have created a custom table(MyTable) inside AX3 and need to purge all
records in MyTable before inserting new records again.

I've tried the usual myTable.delete() but it takes time to delete thousands
of records. I also tried executequery("PURGE TABLE MyTable") but it doesn't
work.

Any suggestion how can I purge all records faster inside Axapta?

Thanks
unknown
2008-07-17 05:42:00 UTC
Permalink
Well, first of all, you can use the delete_from MyTable;
This is much faster than the line-by-line delete. but, will turn into that
in a number of scenarios:
http://msdn.microsoft.com/en-us/library/aa624886.aspx

Also, the fastest way is to truncate the table:

SqlDataDictionary sqlDict;
;
new SqlDataDictionaryPermission(methodStr(SQLDataDictionary,
tableTruncate)).assert();
sqlDict.tableTruncate(tableNum(MyTable), false);
CodeAccessPermission::revertAssert();

And you have to execute this on the server tier!
--
Kashperuk Ivan (Vanya), SDET, Inventory management, Microsoft Dynamics AX
My blog - http://kashperuk.blogspot.com
Download MorphX IT in Russian - http://www.lulu.com/content/723888
Post by portect
Hi,
I have created a custom table(MyTable) inside AX3 and need to purge all
records in MyTable before inserting new records again.
I've tried the usual myTable.delete() but it takes time to delete thousands
of records. I also tried executequery("PURGE TABLE MyTable") but it doesn't
work.
Any suggestion how can I purge all records faster inside Axapta?
Thanks
portect
2008-07-17 08:48:03 UTC
Permalink
thanks!
Post by unknown
Well, first of all, you can use the delete_from MyTable;
This is much faster than the line-by-line delete. but, will turn into that
http://msdn.microsoft.com/en-us/library/aa624886.aspx
SqlDataDictionary sqlDict;
;
new SqlDataDictionaryPermission(methodStr(SQLDataDictionary,
tableTruncate)).assert();
sqlDict.tableTruncate(tableNum(MyTable), false);
CodeAccessPermission::revertAssert();
And you have to execute this on the server tier!
--
Kashperuk Ivan (Vanya), SDET, Inventory management, Microsoft Dynamics AX
My blog - http://kashperuk.blogspot.com
Download MorphX IT in Russian - http://www.lulu.com/content/723888
Post by portect
Hi,
I have created a custom table(MyTable) inside AX3 and need to purge all
records in MyTable before inserting new records again.
I've tried the usual myTable.delete() but it takes time to delete thousands
of records. I also tried executequery("PURGE TABLE MyTable") but it doesn't
work.
Any suggestion how can I purge all records faster inside Axapta?
Thanks
Loading...