SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Are we in all these cities?


Are we in all these cities?

Author
Message
Mean Gene
Mean Gene
SSC Veteran
SSC Veteran (218 reputation)SSC Veteran (218 reputation)SSC Veteran (218 reputation)SSC Veteran (218 reputation)SSC Veteran (218 reputation)SSC Veteran (218 reputation)SSC Veteran (218 reputation)SSC Veteran (218 reputation)

Group: General Forum Members
Points: 218 Visits: 186
How many DBA's execute their code without doing a Parse first?
UMG Developer
UMG Developer
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2712 Visits: 2204
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...
dbuendiab
dbuendiab
SSC-Enthusiastic
SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)

Group: General Forum Members
Points: 157 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.
cetin
cetin
Grasshopper
Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)

Group: General Forum Members
Points: 19 Visits: 27
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 correctSmile 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.
Jamie-2229
Jamie-2229
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3144 Visits: 838
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
spencerpnhcc-alt
spencerpnhcc-alt
SSC Journeyman
SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)

Group: General Forum Members
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.
Jamie-2229
Jamie-2229
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3144 Visits: 838
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
Tom Thomson
Tom Thomson
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14459 Visits: 12228
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

Hugo Kornelis
Hugo Kornelis
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11132 Visits: 12004
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search