"Unhandled expression type" in SQL subquery

158 views Asked by At

I am using XrmToolBox with SQL 4 CDS to make some edits to a user in MS Dynamics. I don't quite know where the error lies-- in the SQL expression? In the FetchXML that it gets converted to? Anyway, here's my expression:

INSERT INTO systemuser (
  firstname,
  lastname,
  internalemailaddress,
  departmentid,
  internalspecialtyid)
VALUES (
  'John',
  'Smith',
  '[email protected]',
  (SELECT TOP 1 departmentid FROM department WHERE name = 'Commercial'),
  (SELECT TOP 1 internalspecialtyid FROM internal_specialties WHERE name = 'B2B Comms'));

When I run this, I get this message from XrmToolBox:

Unhandled expression type: (SELECT TOP 1 departmentid FROM department WHERE name = 'Commercial')

I really don't understand this. I can select the subquery and execute it to get one response back. I can take its results and make it a static (non-subquery) expression with no problem. But why isn't this working? I'm pretty new to SQL, assuming that's where the problem is, so I could easily misunderstand the subquery syntax.

1

There are 1 answers

0
Daryl On

The SQL 4 CDS tool attempts to provide as much a SQL implementation for CDS/Dataverse as possible but it's not perfect. Reach out to the tool author directly by opening an issue on the the SQL 4 CDS's GitHub page: https://github.com/MarkMpn/Sql4Cds/issues