Thursday, October 28, 2010

AX: Getting list of Non AOT tables

Microsoft Dynamics AX,

Getting list of Non AOT tables,
select table_name
from information_schema.tables st
where st.table_name not in (select SQLNAME
from SQLDICTIONARY sd
where sd.FIELDID = 0
and sd.ARRAY=0
AND sd.FLAGS = 0)
and st.table_name <> 'SQLSYSTEMVARIABLES';

Getting record counts for all tables in specific database

Getting list of record count of all tables in specific database,

Query:
sp_msforeachtable '
declare @rowcnt int
select @rowcnt=count(*) from ?
if (@rowcnt>0)
print "?" + str(@rowcnt)
'