Expand all SELECT *'s in large query
At my job I have inherited a large (13000+ line) query with numerous unions of the form:
SELECT * FROM a
UNION
SELECT * FROM b.
We are running into an issue where a and b can end up with different column orders causing this to fail. This is further complicated by that fact that this large query is using these to create hundreds of functions, and these unions are occuring within CTEs.
The solution I would like to do is go onto a database where the columns are currently ordered correctly and use a tool to expand out all of the * into the tables column definitions. Do any of the devart tools have that functionality? I currently have SQL Complete licensed at work and while it works great while writing the query to expand out the *, I can't seem to find a way to do it to all instances of * within that large query.
Thank you for any suggestions.