14 05 2013
SQL Server: Set query governor cost limit
Sometimes you will have the problem that you execute a long, time consuming query, e.g. in a stored procedure.
In our case we’ve got a maintanance plan that executes a stored procedure to generate statistics everey day.
But for this we will the following error on execution: “The query has been canceled because the estimated cost of this query (%d) exceeds the configured threshold of %d. Contact the system administrator.” (http://msdn.microsoft.com/en-us/library/aa337374.aspx)
You can fix this by setting the cost limit to a higher value or zero with the following command:
SET QUERY_GOVERNOR_COST_LIMIT 0
This command will set the cost limit for the current connection.