Thanks for getting in touch! My first thought is perhaps output variables would work for you here, so you can run your SQL query and store what’s returned as an output variable in your step. This should allow you to retrieve the data, store it in the variable and then call the variable all within your deployment process. Would that be a valid approach to addressing your requirement?
Another possibly relevant/similar idea would be to have an API script to add a project variable which you could add as a script in your process. The following script might be a good starting point.
I hope that helps! Let me know what you think, or if I’m misinterpreting anything about what you’re after.