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

SQL syntax Expand / Collapse
Author
Message
Posted Friday, May 28, 2010 8:52 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 3:27 PM
Points: 33,202, Visits: 15,347
I have removed the sentence about error messages since it was confusing.






Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #929733
Posted Friday, May 28, 2010 9:25 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, July 7, 2014 1:04 PM
Points: 13, Visits: 87
I'd have liked to see a 4th option, "none of the above". I believe that would have added to the educational opportunity.

But then, why pose this question at all? Doesn't it promote harder to read code, and the memorization of what is essentially trivia?

select * from table_name

I'd argue that the above statement is: easier to read, doesn't require knowledge of this trivia, works if you substitue "my_column" for the "*", and is probably far more cross platform compatible.

These are meant as constructive criticisms. I do very much appreciate the learning opportunity!
Post #929766
Posted Friday, May 28, 2010 9:48 AM


SSC-Insane

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

Group: General Forum Members
Last Login: Today @ 1:51 PM
Points: 21,644, Visits: 15,317
thanks for the Question



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #929798
Posted Friday, May 28, 2010 10:16 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, October 22, 2012 4:46 PM
Points: 77, Visits: 110
In testing out the theory (not pasting from the examples which inherently include a space before the table name)... only the second query runs without error:

--WON'T RUN: select*fromUDM.DimDate --'no space between select, *, and from


select* from UDM.UDM.DimDate -- 'no space between select and *


--WON'T RUN: select *fromUDM.DimDate-- 'no space between * and from


I ran this against 2005 SQL Server via Management Studio.
Post #929825
Posted Friday, May 28, 2010 10:21 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, October 22, 2012 4:46 PM
Points: 77, Visits: 110
Gotcha! The spacing between Select*from doesn't matter but there must be a space after from for the table name.... THanks for the learning!
Post #929826
Posted Friday, May 28, 2010 10:36 AM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Tuesday, December 7, 2010 12:55 AM
Points: 771, Visits: 504
I personally didn't find the question confusing. And, although the syntax definitely is NOT advisable for readability, etc. it is interesting to know how SSMS will parse some code without the white space.

Thanks for the question.
Post #929834
Posted Friday, May 28, 2010 11:51 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 3:34 PM
Points: 15,661, Visits: 28,051
I would argue that while all three compile and run, none of them is "correct." If they were correct, then so would this be, and you know it's not:
SELECTmycolumnFROM MyTable;
SELECTmycolumn FROM MyTable;
SELECT mycolumnFROM MyTable;

However, I'd leave the question alone. It was interesting to see weirdness in the parser.


----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of: SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #929859
Posted Saturday, May 29, 2010 6:53 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Monday, August 25, 2014 6:32 PM
Points: 11,194, Visits: 11,140
Grant Fritchey (5/28/2010)
I would argue that while all three compile and run, none of them is "correct."

In the same way that 2+2=5 for sufficiently large values of 2?




Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #930036
Posted Saturday, May 29, 2010 6:53 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Monday, August 25, 2014 6:32 PM
Points: 11,194, Visits: 11,140
Nice (but quite shocking!) question. I'm not at all embarrassed to say I got this one wrong.



Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #930037
Posted Tuesday, June 1, 2010 7:49 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, June 3, 2010 3:18 PM
Points: 14, Visits: 6
For me all three options worked. I am using SQL 2008 express edition .
Post #930688
« Prev Topic | Next Topic »

Add to briefcase «««1234»»

Permissions Expand / Collapse