Print All SQL Queries in Magento

Activate the Zend SQL Profiler with the following node in your local.xml:

    <resources>
     <default_setup>
      <connection>
       <profiler>1</profiler>

Then you can access the profiler somewhere in your code and retrieve a lot of informations about all executed queries:

$profiler = Mage::getSingleton('core/resource')
    ->getConnection('core_write')->getProfiler();

To simply output all queries:

print_r($profiler->getQueryProfiles());

Question and answer on StackOverflow