Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
spock
Starting Member
35 Posts |
Posted - 2003-10-13 : 23:50:19
|
| Hi All,I have to validate a query that users type in my site. One way would be to execute the query and see if it runs. But we felt that this was a crude solution.I was trying to find out if there is any method in the SQL Server Com object that offers this functionality. I tried searching in MSDN but was unable to find a match. So any pointers on this would be helpful.Thanks in AdvanceKaushik |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2003-10-14 : 00:56:15
|
| The query is not compiled until it first runs so there's not really any way round that.You can try the estimated query plan but that won't work for some queries.You can also execute with set fmtonly on.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
mohdowais
Sheikh of Yak Knowledge
1456 Posts |
Posted - 2003-10-14 : 02:34:49
|
You mean you have a textbox that says "type your sql query here"? Isn't that dangerous, like what if the user types in "TRUNCATE TABLE Users" and hits Execute?Look at the SET PARSEONLY and SET FMTONLY options. The first looks for syntax errors, but does not compile the query. The second will do both, and executes the statement but returns only column headers.Owais Make it idiot proof and someone will make a better idiot |
 |
|
|
|
|
|