How to validate sql query syntax?

后端 未结 6 2128
忘掉有多难
忘掉有多难 2020-12-09 22:51

java 1.4 Sql server 2000

i am taking input of sql query (for validation of field value against values retrieved by executing sql query) from admin user which will be

6条回答
  •  长情又很酷
    2020-12-09 23:45

    dont think there is any (easy) way to validate sql

    Sql syntax is complex and allows for alot of different ways to enter a statement.

    Think you best shot would be to just execute the sql statent and if you have a SQl exception see if its a bad syntax thats causing it.

    you can prepend some sql to avoid from actually executing the query

    in sybase it would be SET NOEXEC ON

提交回复
热议问题