More Efficient Grant Script for Microsoft Dynamics GP

Microsoft Dynamics GPI’m not sure how, but I stumbled across an article on the ERP Software Blog by Michael Krasivsky of The Resource Group where he has posted a more efficient version of the Grant.sql script.

For those who don’t know, the Grant script is used to apply the correct permissions to SQL objects (tables, views and stored procedures) used by Microsoft Dynamics GP; this script can take a while to run as it utilises a cursor to update the permissions on every single SQL objects in the database regardless of the current permissions.

What Michael has done is create a script which only selects the SQL objects which do not have the correct permissions and grant them on those objects only; this makes the script much faster to run, as in most cases the majority of the SQL objects will already have the correct permissions so it is only a minority of objects which need to be updated.