HomeActive Query BuilderHow to validate SQL

How to validate SQL


Hi,
I would like to know if there is any way to know that the SQL built by the query builder is a valid SQL. Currently I directly execute the SQL built by user and sometimes it gives syntax error. So how can I validate the SQL (it will return some/no result but not an error) without actually executing it in database?
Thanks,
Ajit
Ajit T | email
September 26 2007, 10:05 AM
Dear Ajit,

No, we do not perform validity check against specific database, and actually we believe that the only possible validator is the database server itself. Of course, you can check if such database objects and fields are exist in the database (using the QueryStatistics property), but still there are many things we can recognize if they correct in terms of specific database or not.

The fastest way to do that is to call the following method: SqlCommand.ExecuteReader(CommandBehavior.SchemaOnly).
This will execute the query without data retrieval.

Hope this helps.
Sergey Smagin | email
15 hours, 48 mins since original post
This topic is closed