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 «««23456»»

Are we in all these cities? Expand / Collapse
Author
Message
Posted Wednesday, July 14, 2010 9:34 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, November 6, 2014 8:33 AM
Points: 218, Visits: 166
How many DBA's execute their code without doing a Parse first?

Post #952452
Posted Wednesday, July 14, 2010 9:40 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, September 5, 2014 2:00 PM
Points: 2,160, Visits: 2,191
WayneS (7/14/2010)
I have to admit that I got this correct, but for the wrong reason. In looking at the question
Using the default Northwind database on a default install of SQL Server 2008 SP1
, I figured that since the Northwind database is NOT part of a default install of SQL, that it would error out. With all the emphasis on the "default"s, I figured it was a trick question.


You know when I was reading the question I was thinking the same thing, but then said no, that wouldn't be it...
Post #952462
Posted Thursday, July 15, 2010 12:38 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Tuesday, May 14, 2013 11:41 AM
Points: 77, Visits: 218
It's a cheat question not worth the time one put on it.

Next time you could misspell a word, maybe a column name, and you'll get a even better query.

Don't waste our time, please.
Post #952875
Posted Thursday, July 15, 2010 7:15 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, October 10, 2013 9:11 AM
Points: 11, Visits: 25
This was one of those questions with no purpose. I too got it wrong because I even didn't look to author's syntax error. I was thinking why none of the replies were correct:) Damn then I should guess it was something like ajoke and mark the error. I wasn't really looking at these daily questions but today decided to. This was the 3rd one in questions and now I know that I was right not bothering to answer to questions.
Post #953103
Posted Saturday, July 17, 2010 4:27 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 7:43 PM
Points: 2,703, Visits: 790
When I read the question, I can see the semi-colon doesn't belong there and it looks like an error in the question. Many of us come from visual basic, not c sharp. We can safely ignore semi-colons in visual basic. However, I see the point, learned something; I'm just not happy about it - seems more like a trick to me than anything else.


How many DBA's execute their code without doing a Parse first?


I hate that nasty green arrow. Sometimes I miss and hit that instead of execute. I never parse... that's for DBA's who are unsure of how to write queries (IMHO). I'm sure there are DBA's better than I who do parse. I do not parse.


Jamie
Post #954453
Posted Friday, July 23, 2010 1:58 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, September 22, 2011 12:47 PM
Points: 93, Visits: 49
I totally missed that spurious semicolon in the subquery.

I was focused on the logic of the statement, and not a spurious typo.

This question TOTALLY FAILS to illustrate any point about a correlated subquery. The only point this question illustrates is that I was not careful enough in my review of the statement, and that including an invalid token in a SQL statement is a syntax error.

I could get the exact same result with a misspelled a keyword.



Post #958248
Posted Friday, July 23, 2010 2:49 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 7:43 PM
Points: 2,703, Visits: 790
I totally missed that spurious semicolon in the subquery.

I was focused on the logic of the statement, and not a spurious typo.


Good to hear someone put what I felt here into words.


Jamie
Post #958288
Posted Monday, July 26, 2010 6:31 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 7:18 PM
Points: 7,930, Visits: 9,654
Hugo Kornelis (7/13/2010)
I hope the author will stop by and tell us what he/she was trying to teach us with this question. Maybe I missed the deeper issue here.

I guess the deep issue here is that code-reading/checking is an important part of many jobs; most of us tend to skim read and not notice errors, so it's as well to be reminded now and again tha reading is important. I'm pretty lazy about this for my own code and it would be a crime if I fed my stuff into execution without getting the parser to do a syntax check first, but I have had to evaluate other people's code too so the occassional reminder that I should look more carefully is a good thing, because there is always the risk that if one is skimming so that syntax errors are missed maybe some errors of logic will be missed too because one is not reading carefully enough.

Incidentally, I was unpleasantly surprised by the introduction of mandatory semicolons into what should be a nice clean syntax that can be parsed unambiguously without these markers. I wonder whether something has been added to the language that genuinely prevents detection of some statement boundaries without specific separators (that would be a pretty stupid thing to do, but I've seen stupider things happen) or was some parser development team just too lazy to do it right; and I'm sad to see that MS is planning to make unneeded separators mandatory at some point in the future.


Tom
Post #959154
Posted Sunday, August 1, 2010 3:24 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 11:43 AM
Points: 6,149, Visits: 8,409
Tom.Thomson (7/26/2010)
Incidentally, I was unpleasantly surprised by the introduction of mandatory semicolons into what should be a nice clean syntax that can be parsed unambiguously without these markers. I wonder whether something has been added to the language that genuinely prevents detection of some statement boundaries without specific separators (that would be a pretty stupid thing to do, but I've seen stupider things happen) or was some parser development team just too lazy to do it right; and I'm sad to see that MS is planning to make unneeded separators mandatory at some point in the future.

As far as I know (and I'm too lazy to check right now), the semicolon has always been mandatory in ANSI SQL.

I'm glad it will become mandatory. One of my worst nightmares was when a coworker was repairing bad data in a production environment. To make sure he got the WHERE clause perfect to find only the rows to be removed, he used this code:
--DELETE FROM TheTable
SELECT FROM TheTable
WHERE (very complex clause)

When he finally had the WHERE clause perfect, he uncommented the DELETE, then hit the EXECUTE button.
This was the only time we were all glad that the triggers on this table were so painfully slow (they used row by row processing, in a very inefficient way to boot). After a few minutes, the phone started ringing because all users were blocked; we were able to kill the process before it finished. Which saved us a LOT of grief, since that database was in the simple recovery model.
With a mandatory semicolon statement seperator, this mistake would simply have returned an error message.

Also, while it may be possible to build a parser that does it job without needing semicolons, evenn Microsoft has limited resources - I'd rather see them spend those on new features rather than maintaining a parser that could be simplified by simply requiring semicolons.



Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Post #961937
Posted Wednesday, September 22, 2010 9:14 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, December 19, 2014 3:48 PM
Points: 1,107, Visits: 1,245
Thanks for the question. I was ticked since I got it wrong, but it is too easy to just gloss over a script when reading it. A good reminder to be careful.

-Dan



Post #991275
« Prev Topic | Next Topic »

Add to briefcase «««23456»»

Permissions Expand / Collapse