Skip to main content
Microsoft Dynamics AX forum
Suggested answer

I want to change SQL statement to X++ Code need help

editSubscribe (0) ShareShare
ReportReport
Posted on by 10


Statement 1  -   delete top (333114963) SALESPARMLINE from SALESPARMLINE t where not exists (select 1 from SALESPARMTABLE d where d.Partition = t.Partition and d.dataAreaId = t.dataAreaId and d.ParmId = t.ParmId and d.TableRefId = t.TableRefId)


Statement 2 -   delete top (21308858) SALESPARMSUBLINE FROM SALESPARMSUBLINE t where not exists (select 1 from SALESPARMLINE d where d.RecId = t.LineRefRecId)
Attachments
  • Deepak Agarwal Profile Picture
    Deepak Agarwal 127 on at
    I want to change SQL statement to X++ Code need help
    Please clarify the question and what you are trying to achieve . 
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 223,025 Super User on at
    I want to change SQL statement to X++ Code need help
    Use delete_from statement together with notexists join. Use crossCompany keyword if you want to run it for all companies.
     
    For example:
    delete_from crossCompany salesParmLine
        notexists join salesParmTable
        where salesParmTable.ParmId == salesParmLine.ParmId
           && salesParmTable.TableRefId == salesParmLine.TableRefId;
  • Community member Profile Picture
    Community member 10 on at
    I want to change SQL statement to X++ Code need help
    I want it to converted to X++ code for Delete records by creating batchJob 
     
  • Martin Dráb Profile Picture
    Martin Dráb 223,025 Super User on at
    I want to change SQL statement to X++ Code need help
    Well, you'll need to tell us what change you want to make and what kind of help you need from us, otherwise we can't do anything for you.

Helpful resources

Quick Links

New Blog Features Released!

Check out the new community blog features for viewers and authors…

Demystifying Copilot with Sundar Raghavan

Sundar explains how Copilot for Service is meant to function separately...

Business Process Guidance Badges and New…

The Microsoft Success by Design is the framework for implementing Dynamics 365…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,281 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 223,025 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,140

Featured topics

Product updates

Dynamics 365 release plans