We upgraded from CRM 2011 to 2013, and when we select Sales > Accounts > Contracts we get a SQL error:
SQL Server Error
A SQL Server error occurred
Running the SQL profiler shows an invalid query being constructed by CRM when opening the contract. The queries sent to SQL Server 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 query has an invalid "select" in the query and it seems to be missing an "and exists (select". The error appearsto be a bug in CRM 2013. I would appreciate any help to resolve the issue or a workaround.
Carlos