web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Translating T-SQL query to x++

(1) ShareShare
ReportReport
Posted on by 1,400

Hi guys, I'm trying to convert the following T-SQL query to x++:

INSERT INTO 
TABLE1
(COLUMN1, COLUMN2, COLUMN3)
SELECT
@VARIABLE1 AS COLUMN1,
@VARIABLE2 AS COLUMN2,
TABLE2.COLUMN3 AS COLUMN3
FROM 
#TABLE2 TABLE2 
LEFT JOIN TABLE1 WITH (NOLOCK) ON
TABLE1.COLUMN1 = TABLE2.COLUMN1
AND TABLE1.COLUMN2 = @SOMEVARIABLE
WHERE
TABLE1.COLUMN3 IS NULL

but when I wrote it in x++, it came out like this:

while select column3
from table2
where table1.column3 == ''
outer join table1 
where table1.column1 == table2.column1
&& table1.column2 == someVariable
{
table1.column1 = variable1;
table1.column2 = variable2;
table1.column3 = table2.column3;
insertRecordList.Add(table1);
}
insertRecordList.insertDatabase();


Which I'm pretty sure it's wrong because it won't filter on that first 'where' clause, as the table buffer is still empty at that point (I believe).

What would be the appropriate way to translate that to x++? Am I approaching this the wrong way?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    238,745 Most Valuable Professional on at

    Are you aware of insert_recordset? It would be closer to the original SQL code.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Sagar Suman Profile Picture

Sagar Suman 2 Super User 2026 Season 1

#1
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#1
Pratik Bhosle Profile Picture

Pratik Bhosle 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans