We are getting the same error after upgrading from CRM 2011 to 2013. Running the SQL profiler is showing an invalid query constructed by CRM when opening a contract. The invalid queries are
create table #RollupIds(RollupId uniqueidentifier PRIMARY KEY CLUSTERED)
create statistics rupstat on #RollupIds(RollupId)
select
DISTINCT top 251 "contract0".Title as "title"
, "contract0".StateCode as "statecode"
, "contract0".ActiveOn as "activeon"
, "contract0".ExpiresOn as "expireson"
, "contract0".ContractId as "contractid"
from
ContractBase as "contract0" (NOLOCK)
where
(("contract0".ContractId in (select contract0.ContractId from Contract as contract0 WITH (NOLOCK) where exists (select RollupId from #RollupIds where RollupId = contract0.CustomerId)select
contract0.ContractId from Contract as contract0 WITH (NOLOCK) where exists (select RollupId from #RollupIds where RollupId = contract0.BillingCustomerId)))) order by
"contract0".Title asc
, "contract0".ContractId asc
the bolded select is invalid as it is missing an "and exists". This error seems to be a bug in CRM 2013. I would appreciate if anyone has found a workaround or a solution to this issue.
Carlos