Aside from the concerns about security and embedded statements, etc, is there a way to submit a Query to SQL Server for validation?
I'm creating an application that will allow the user to sort of roll their own in creating filter expressions. I'd like to be able to submit these for syntax validation before submitting for actual processing.
Are you constructing this sql in application code or embedding this inside a stored procedure? You definitely need to check the syntax of the queries generated before actually sending for query processing. How to do it depends on where you are writing these queries. If inside a SP then you should be able to capture teh sql inside a variable and print the variable to test the code. someting like...Code Snippet
set@str = N'select au_id, au_lname from dbo.authors' --I have simplified the details here and we know its more complex than this stmt.
If you are doing this in application code then it gets tricky to separate out the application variables. I am not sure if there is an easy way out of this. If there is pre-defined pattern to construct the queries then you should be able to embed them in stored procedures and pass in parameters to SP's to adjust accordingly.