Article
Authorization error: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression
14:54 Jan 30, 2018
Symptoms
The error occurs when login and passowrd are entered:
Exception Message: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Exception Type: System.Data.SqlClient.SqlException
Exception Source: .Net SqlClient Data Provider
Cause
The error might be caused by update.
Permission duplicates with equal positions.
Solution
Find the duplicate permission name (Code) via a request:
select SAO.Code, SAOG.Position, count(sao.id) from sysadminoperationgrantee SAOG join SysAdminOperation SAO on SAO.ID = SAOG.SysAdminOperationId join SysAdminUnit SAU on SAU.ID = SAOG.SysAdminUnitId group by SAO.Code, SAOG.Position having count(sao.id) > 1
After you find the name (e.g., "CanUseSharedMailBox"), find the list of record IDs that are duplicates.
SELECT * FROM SysAdminOperationGrantee WHERE SysAdminOperationId = (SELECT Id FROM SysAdminOperation WHERE Code = 'CanUseSharedMailBox')
After that, change the number of position in one of the records (does not matter which record). As a result, no duplicates will occur.
UPDATE SysAdminOperationGrantee SET Position = 1 WHERE Id = 'C3665747-F6F6-474F-8CEE-5A7678883F4B'