Change the AggregateQueryRecordLimit for 1 organization

In CRM there are a couple of thresholds created to guarantee performance of the application. Though this is a good thing, it does cause some issues every now and then. One of these thresholds is the AggregateQueryRecordLimit.

You will find that CRM uses this threshold as soon as you want to view a chart or execute an aggregation in a report over more than 50.000 records. If this is the case, then CRM will present you with the error message "AggregateQueryRecordLimit exceeded. Cannot perform this operation.".

Multiple guys have posted about changing this setting (hint:
update DeploymentProperties set IntColumn = 250000 where ColumnName = ‘AggregateQueryRecordLimit’), but this allows every organization in your instance to exceed this threshold, while you might only want to allow one organization to do this.

Though it is not documented in the SDK, it is possible to set this value for just a single organization. Just as easy as updating the deploymentproperties table, you can also add a record to the organizationproperties table (in the MSCRM_CONFIG database):

INSERT INTO MSCRM_CONFIG.dbo.OrganizationProperties (Id, ColumnName, IntColumn)
VALUES ('8CB2768E-1585-E411-80BC-D4490D33C5AC', N'AggregateQueryRecordLimit', 250000)

Obviously you'll need to replace the guid with the ID of your organization (select id, FriendlyName from Organization) and the number in the end with the amount of records you would allow to be aggregated.