Error: "Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression" - When using Contact (Primary) field in a constituent query

When using the Contact (Primary) fields in a constituent ad-hoc query, you might encounter the error "Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression."
This is caused by organization records having more than one primary contact on the relationship tab. Deleting the duplicate primary contact relationships will resolve this issue. To find organizations that have this problem, run the select statement below:
 

--Duplicate primary contacts

select RELATIONSHIPCONSTITUENTID, RECIPROCALCONSTITUENTID, ISPRIMARYCONTACT, count(*)

from dbo.RELATIONSHIP R

where ISPRIMARYCONTACT = 1

group by RELATIONSHIPCONSTITUENTID, RECIPROCALCONSTITUENTID, ISPRIMARYCONTACT

having count (*) > 1

Steps to Duplicate

1) Create a constituent ad-hoc query
2) Filter using any field with Contact (Primary) or display any Contact (Primary) fields in the results
3) After a few seconds, notice that the error is thrown.

Environment

 Blackbaud CRM
 4.0
 4.0.172.0

Was this article helpful?