I built a flow in Power Automate a while ago to send rows to a Google Sheet.
It makes use of the Get Rows (v2) for SQL
For simplicity in my Select Query I use a view which is built from a much more complex SQL query on the database (so all I have to do is select column names).
This has all worked great. Now the client asks me to add in 3 extra columns. One of the requirements is getting the earliest date from multiple date columns as a single column. I delete the view, add in the three columns and rebuild it. Query it in SSMS, all working fine.
Then I go to add in the 3 extra columns, comma separated into the Select Query in Get Rows (v2) in Power Automate.
I get an error:
"status": 400,
"message": "The column '[thenameofmycolumn]' of the table wasn't found.
I double check my select is exactly the same, down to case sensitivity, and they are.
I remove each column and add it in one at a time to see if its some weird thing with a particular column. One works fine, but the other two don't.
I check if its to do with a column limit by removing other columns, but its not that either.
Finally I try removing a column that errors in the design view in SSMS. It's built in the SQL like:
,(SELECT MIN(ArrayofDates)
FROM (VALUES (Date1),(Date1),(Date1),(Date1),(Date1),(Date1),(Date1)) AS EarliestDate(ArrayofDates)) as ArrayofDates
Which outputs the earliest date of the group of dates. Works fine in running query, works fine in CREATE VIEW, and works fine in Select of the view, but if I right click the view and select design I get:
Error in FROM clause: near 'VALUES'.
Error in FROM clause: near ')'.
Unable to parse query text.
I'm tearing my hair out at this point - It is not a typo on my behalf. Why is Power Automate doing this? Does GetRows have some weird interaction or something I'm not understanding with views that give Design view errors? If I have to I'll resort to a CASE statement to see if it gets around the issue but its a PitA to write a CASE statement compared to the statement above.