If you know database structure in AX 2012, you can directly select data from SQL Server. Of course select data from SQL Server are faster than select data from AX 2012 framework.
In AX 2012, you can run report inventory to get On-hand data. To access it, use this navigation : Inventory management -> Reports -> Physical inventory -> Physical inventory by inventory dimension. Use parameter below to run report :