Converting BAQ to a SQL Query

I have a query that i’ve written, it is for excess and obsolete inventory. Lots of ins and outs, about 21 subqueries. The corporate data center wants to pull this query directly into Power BI. In the past I was able to debug the sql in SQL Management Studio by just dumping the epicor version in but this one is pretty big and it is throwing tons of errors.

I tried to run a query execution plan but it cuts off about 1/3 of the way through the query text.
I used the server profiler to get the query as it ran but when I put it back in into the studio it looks like it modified the query (example double quotes instead of single quotes in calculated fields)
We will be implementing REST next upgrade.

Any ideas?

It looks like I had to grab the declarations from the profiler, with those I can run in the management studio.