If you have ever asked yourself the question "What is my data distribution by company(PARTITION an or DATAAREAID) for a specific Dynamics AX table?", wonder no longer. Attached is a TSQL Stored Procedure you can add to your Dynamics AX database (4.0, 2009, 2012, 2012 R2...) and then run it against any table in the Dynamics AX database that has includes the DATAAREAID column and it will should you the data distribution for all existing companies. When you run the Stored Procedure against a specific table the output will look like the example below.
Example: Versions earlier than Dynamics AX 2012 R2
Example: Version Dynamics AX 2012 R2 and later(?)
The TSQL Stored Procedure is attached to this BLOG post, to build it just run the script against the Dynamics AX Database.
The syntax to run the Stored Procedure is as follows
EXEC sp_datadistrbution_by_parition_dataareaid_by_table 'XXXXXXXXXX'
where XXXXXXX is the Dynamics AX Table name
I use this to determine whether Parameter Sniffing may be an issue or not.