|
|
|
SSC-Insane
         
Group: General Forum Members
Last Login: Yesterday @ 8:44 PM
Points: 21,376,
Visits: 9,585
|
|
| For anyone who cares to know, this behavesas stated in the explaination both for 2005 and 2008 of ma machine (latest services packs).
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Friday, September 28, 2012 8:38 AM
Points: 466,
Visits: 165
|
|
Brilliant question! The nested comment scenario is probably more common that one might think. This is a non-intuitive behavior, yet great to be aware of. Thank You!
Regards,
Jim C
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Tuesday, June 11, 2013 2:08 PM
Points: 2,121,
Visits: 2,226
|
|
Fiendish question, yet practical. (I got it wrong by choosing 1,4,5,7,8)
Nice work.
Thanks, webrunner
------------------- "The chemistry must be respected." - Walter White
"A SQL query walks into a bar and sees two tables. He walks up to them and says 'Can I join you?'" Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Friday, February 04, 2011 7:20 AM
Points: 977,
Visits: 1,499
|
|
That was FUN!
With all of the commenting that I use, permanent and temporary, I knew this would be a cinch. And like everyone else, I got it wrong. I think the logic is wrong, and that it shouldn't work that way, but what do I know.
I would like to hear from the 48% that got it right. Did any of you get it right without trying it first?
Thanks for a neat QOD.
Tom Garth Vertical Solutions
"There are three kinds of men. The one that learns by reading. The few who learn by observation. The rest of them have to pee on the electric fence for themselves." -- Will Rogers
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 8:07 AM
Points: 1,190,
Visits: 359
|
|
This was a pretty good catch!
It got me 
Who the heck would use comments like that. I practice the KISS method which stands for "Keep It Simple Stupid". I use this as much as possible.
D. Couturier Database Administrator & Architect
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: 2 days ago @ 9:24 AM
Points: 395,
Visits: 235
|
|
This is really exciting question. I always had feelings that /* */ has priority on – . And construction like -- /* will lead SQL to ignore /*. I was wrong! Thank you for so useful information and good lesson.
Artur
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Monday, May 06, 2013 8:47 AM
Points: 304,
Visits: 552
|
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Friday, June 08, 2012 7:51 AM
Points: 1,219,
Visits: 225
|
|
TO Russell, What version of management studio did you use? In studio 2005 I got 1, 5, 8. I triple checked the executed code to make sure it was the same as the problem shown.
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Tuesday, June 11, 2013 6:27 AM
Points: 330,
Visits: 187
|
|
I'm using Microsoft SQL Server Management Studio version 9.00.2047.00
I get 1, 4, 5 and 8. Where has your 4 gone?
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Friday, June 08, 2012 7:51 AM
Points: 1,219,
Visits: 225
|
|
Using Studio 9.00.3042.00
PRINT '1' -- /* ;PRINT '2' */ ;PRINT '3' /* PRINT '4' --*/ --/* PRINT '5' --*/ /* PRINT '6' --/* */ PRINT '7' --*/ PRINT '8'
yields a return of:
1 5 8
The parser only shows PRINT '1' , PRINT '5' and PRINT '8' in blue, the rest of the PRINT statements are Green (comments) SQL Server 2005 64-Bit on Sun 4600
|
|
|
|