Hi,
This is new blog on knowledge share, today just got chance to work with SQL queries; i was just exploring the dimension extract for one of our customer, i produce this sql query which show main account and financial dimensions associated with main account; i though it is worth to share with AX community also.
-- This script is designed to show the values in columns for better read-- Deleting if tmp table already existsBegindroptable#MainAccountDimensionTmpEnd-- creating new Tmp table.BeginCREATETABLE#MainAccountDimensionTmp ( MainAccount nvarchar(100), DisplayValue nvarchar(100), Name nvarchar(100) ) End-- selecting main accounts and all financial dimensions and storing into tmp tableBeginInsertinto#MainAccountDimensionTmp (Name, DisplayValue, MainAccount)select ddv.NAME, ddv.DISPLAYVALUE, MAINACCOUNT.MAINACCOUNTIDfrom MainAccountLegalEntity as MALEjoin MAINACCOUNT on MAINACCOUNT.RECID = MALE.MAINACCOUNTjoin DEFAULTDIMENSIONVIEW as ddv on MALE.DEFAULTDIMENSION = ddv.DEFAULTDIMENSION --where MAINACCOUNTid = 'test01'end-- reading again from tmp table in way that values are showin in column.-- please add as many dimesions as you want, like i have added 4 dimensins below.Select MainAccount,MAX(Case Name When'Department'then DISPLAYVALUE ELSE''END ) AS'Department',MAX(Case Name when'ICP'then DisplayValue ELSE''END ) AS'ICP',MAX(Case Name when'MISC'then DisplayValue ELSE''END ) AS'MISC',MAX(Case Name when'Expense_Class'then DisplayValue ELSE''END ) AS'Expense Class'from#MainAccountDimensionTmp Groupby MainAccount --select * from DEFAULTDIMENSIONVIEW
Query results: