Steve Jones - Editor (2/19/2008)
You cannot get the actual execution plan in all cases, so the statement is false. Even if you query the system views, you get the estimated execution plan. That's still estimated, and could change if conditions on the server change between your estimated run and the actual query execution.
The exact question was, "Can you get the actual execution plan SQL Server will use without executing the query?" It does not say, "is it possible in all cases to get the actual execution plan without running the query?", it says "Can you..." That means, in standard English parsing, "is it ever possible ..."
For example, to argue the case, if I ask, "On a trampoline, can you jump more than 3 feet vertically?", the answer is "yes". The fact that not all jumps will necessarily be more than 3 feet does not change the answer to "no". It doesn't even matter if you never get on a trampoline, or never jump higher than 2 inches if you do get on one, the very fact that it is possible answers the question of "can you" as "yes".
That's standard use of the English language.
If the question required an answer about all possible cases, it should have been worded differently.
I try to hold use of English to the same standards that I hold use of SQL (or any other programming language).
If someone handed you a query:
where Col1 = 0
and asked if that query will give you the rows with 0 in Col1, would you say, "no", because there might not be any rows with 0 in that column? No. You'd say, "yes", because that's what the query is obviously designed to do. It's very precise, very exact, and has a definite meaning.
Using "can you" as "Is there a way to always", is the same as using:
if Col1 = 0
It can be read by a human being as having a syntactically identical meaning, but in the language it is being presented in, it's incorrect. (It's always amusing to me that some of the very people who will stand up firmly for standards in their code use and database design, will reject the idea that standards apply to English. Not saying that applies here, just an amusing observation.)
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon