Skip to content

[BUG] Object reference not set to an instance of an object When Running exists #713

Description

@SiPurdy

Describe the bug
Trying to run updates dependant on an attribute existing however getting a Object reference not set to an instance of an object when running the query.

To Reproduce

if exists(select
    *
from metadata.attribute
where
    entitylogicalname='new_thetable' and
    logicalname='new_thecolumn') begin
   print 'Run Update'
end

Expected behaviour
If the subquery in the exists returns a record, the print statement should run (it errors), if the subquery doesn't return a record, no additional output is included (this does happen so the error only happens if the exists actually exists).

Environment (please complete the following information):

  • SQL 4 CDS 10.1.0 within XrmToolkbox and direct through MarkMpn.Sql4Cds.Engine.
  • Results of SELECT @@VERSION:
    Microsoft Dataverse - 9.2.25101.151
    SQL 4 CDS - 10.1.0.0
    Sep 04 2025 07:02:14
    Copyright © 2020 - 2025 Mark Carrington

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions