Getting a dynamically built JS query to execute and return the output

Since you are already building the query in a JS Statement, you could try to declare a SQL parameter that is set to the value of that statement, and then EXEC(@theStatement).

1 Like