September 13, 2012 at 3:42 am
A good and tricky one. Thank you.
September 13, 2012 at 3:48 am
Hugo Kornelis (9/13/2012)
Finally, I can give you one example where this knowledge can be useful: when you have a co-worker whose idea of fun it is to change the batch seperator to, for instance, "SELECT" when you are away from your keyboard, and then watch you struggle to understand why your code is not working anymore. After this QotD, you will probably be able to recognise and fix the problem much faster than you otherwise would have.
+1
Few minutes ago did this on my coworker's system and provided this link qtod to solve it.... (for him I was genius.... :hehe: )
ww; Raghu
--
The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.
September 13, 2012 at 4:13 am
Misread the true meaning of the question so got it wrong. Thanks for the followup discussion as I struggled with this one.
September 13, 2012 at 4:55 am
Good question
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
September 13, 2012 at 4:56 am
Learned something but it was a horribly presented question. Can't believe it got through any type of quality assurance.
September 13, 2012 at 4:58 am
Thanks for the question. I got it right, but did so with a semi-educated guess. I reasoned that, if the answer was FALSE, this is a useless question of a type on which you can make unlimited variations. Might I suggest that a better way to express the same idea is to say something like:
In what way can the query be made to run as written?
A. Hop on one leg
B. Pat your head
C. Eat kippers for breakfast
[font="Verdana"]Please don't go. The drones need you. They look up to you.[/font]
Connect to me on LinkedIn
September 13, 2012 at 5:10 am
Raghavendra Mudugal (9/13/2012)
Hugo Kornelis (9/13/2012)
Finally, I can give you one example where this knowledge can be useful: when you have a co-worker whose idea of fun it is to change the batch seperator to, for instance, "SELECT" when you are away from your keyboard, and then watch you struggle to understand why your code is not working anymore. After this QotD, you will probably be able to recognise and fix the problem much faster than you otherwise would have.+1
Few minutes ago did this on my coworker's system and provided this link qtod to solve it.... (for him I was genius.... :hehe: )
I'm not so brave 😛
September 13, 2012 at 5:36 am
I got the answer right but got the intention of the question wrong.
When I thought, can I get that script to run without changing it, my method to achieve this was to run them individually as 2 separate batches by highlighting each batch minus the batch separator..
I obviously missed the point of this question :ermm:
September 13, 2012 at 5:51 am
For those who are curious on how to change the batch terminator:
Best to copy and paste the above link rather than direcly clicking on it.
September 13, 2012 at 5:53 am
arthurolcot (9/13/2012)
I got the answer right but got the intention of the question wrong.When I thought, can I get that script to run without changing it, my method to achieve this was to run them individually as 2 separate batches by highlighting each batch minus the batch separator..
I obviously missed the point of this question :ermm:
I think that is the problem. It was very easy to miss the point of the question.
September 13, 2012 at 5:54 am
arthurolcot (9/13/2012)
I got the answer right but got the intention of the question wrong.When I thought, can I get that script to run without changing it, my method to achieve this was to run them individually as 2 separate batches by highlighting each batch minus the batch separator..
I obviously missed the point of this question :ermm:
Does it matter? You solved the problem.
Another method: Write a program in your favourite language (C#, C++ ...) that connects to the database, splits the input using notgo, and runs the separated batches.
As all these steps aside are correct, I don't understand the majority of False answers.
September 13, 2012 at 6:18 am
Followed my usual practice of looking through the documentation, got briefly sidetracked by focusing on the two variable declarations (thinking that I needed to find a way to force the 'NotGo' to be ignored), then found the correct answer. While the wording is slightly non-standard, the question is easily understood and the correct answer wasn't THAT difficult to find. Learned something (useful or not) so this is a good day!
Edit: Correct answer being defined as the answer given by the question author, as I see that others found different ways to solve the problem.
September 13, 2012 at 6:25 am
I knew the correct answer, but only because I used my mind reading skills to extract the missing part of the question.
"Can the following script be made to run in SSMS without changes to the script and without error?"
Yes, I can make it execute successfully in SSMS, but I can never get it to work with .NET or any other programming language.
September 13, 2012 at 6:31 am
Nils Gustav Stråbø (9/13/2012)
Yes, I can make it execute successfully in SSMS, but I can never get it to work with .NET or any other programming language.
Nor would you if the script had used "GO" instead of "NotGo", as sending a "GO" to SQL Server from .NET or other client program will also result in an error.
You'd have to write the .NET (or other) code such to recognise the GO as a batch terminator, then send everything up to that GO as one batch, then everything following that GO as the next batch. And if you can do that with "GO" as the batch seperator, you can do so with "NotGo" too. (Though I have no idea why you'd want to).
September 13, 2012 at 6:31 am
I am not crazy about the wording, but I did learn about batch separators once I found where the setting was in SSMS.
-- Go to Tools -> Options -> Change the Batch Separator to EndBatch from GO.
Painful, but I'll get over it.
Viewing 15 posts - 16 through 30 (of 82 total)
You must be logged in to reply to this topic. Login to reply