Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12345»»»

Complicated Comments Expand / Collapse
Author
Message
Posted Wednesday, February 11, 2009 6:27 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Friday, September 12, 2014 10:44 AM
Points: 20,572, Visits: 9,617
For anyone who cares to know, this behavesas stated in the explaination both for 2005 and 2008 of ma machine (latest services packs).
Post #654728
Posted Wednesday, February 11, 2009 6:43 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Friday, August 29, 2014 1:10 PM
Points: 466, Visits: 172
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

Post #654745
Posted Wednesday, February 11, 2009 6:59 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 8:20 AM
Points: 2,373, Visits: 2,726
Fiendish question, yet practical. (I got it wrong by choosing 1,4,5,7,8)

Nice work.

Thanks,
webrunner


-------------------
"Operator! Give me the number for 911!" - Homer Simpson

"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
Post #654767
Posted Wednesday, February 11, 2009 7:27 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Friday, February 4, 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
Post #654808
Posted Wednesday, February 11, 2009 7:38 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, April 25, 2014 9:08 AM
Points: 1,190, Visits: 364
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
Post #654821
Posted Wednesday, February 11, 2009 7:41 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Thursday, September 11, 2014 2:06 PM
Points: 448, Visits: 280
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



Post #654825
Posted Wednesday, February 11, 2009 7:49 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, September 4, 2014 11:21 AM
Points: 305, Visits: 566
I'm glad that everyone seemed to like the question (and surprising answer); I wondered whether people would object to the obscure nature of the problem.

This scenario came up when I started investigating the comparison of lines of text between stored procedures (http://jessesql.blogspot.com/2009/02/comparing-stored-procedures-part-1.html). I wanted to allow the possibility in the comparison of suppressing comments - that's when I discovered this rather odd feature of commenting.


Jesse McLain
jesse@jessemclain.com
www.jessemclain.com
www.jessesql.blogspot.com
Post #654832
Posted Wednesday, February 11, 2009 7:56 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, October 18, 2013 8:39 AM
Points: 1,219, Visits: 226
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.
Post #654845
Posted Wednesday, February 11, 2009 8:02 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, September 10, 2014 2:17 AM
Points: 362, Visits: 226
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?
Post #654859
Posted Wednesday, February 11, 2009 8:07 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, October 18, 2013 8:39 AM
Points: 1,219, Visits: 226
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
Post #654870
« Prev Topic | Next Topic »

Add to briefcase ««12345»»»

Permissions Expand / Collapse