Michael Johnson gets us started playing with SQL Server cursors to get at Dynamics GP data in his new post Row by row analysis and execution with Cursors.
Row by row analysis and execution with Cursors in SQL Server and Dynamics GP
SQL & DataInstall, Upgrade & Admin
Archived post from 2010. Dynamics GP and the links it points to have changed since; check current documentation before relying on version-specific steps.