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
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
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):
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