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 «««123

Unary & Aliases Expand / Collapse
Author
Message
Posted Tuesday, September 13, 2011 4:30 PM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: 2 days ago @ 4:56 PM
Points: 8,271, Visits: 8,717
Amusing and fairly easy question.

The misprints in the explanation may have left some people confused. All three alias forms are wrong (1st missing "= <", second and third bpth missing "alias").

edit: I can make typos too. Fixed.


Tom
Post #1174546
Posted Tuesday, September 13, 2011 4:45 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 9:32 PM
Points: 1,315, Visits: 485
Good puzzler - thanks. Nice coverage of different scenarios.
Post #1174555
Posted Wednesday, September 14, 2011 1:41 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, April 14, 2014 3:30 AM
Points: 2,390, Visits: 2,281
Tom.Thomson (9/13/2011)
Amusing and fairly easy question.

The misprints in the explanation may have left some people confused. All three alias forms are wrong (1st missing "= <", second and third bpth missing "alias").

edit: I can make typos too. Fixed.

Unfortunately, the editor to contribute with a question, sometime, changes the text both in the question and more often in the explanation. The explanation was victim of this change. I think because of GREAT and LESS sign that are misinterpreted as html syntax.
Post #1174695
Posted Wednesday, September 14, 2011 1:56 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, April 14, 2014 3:30 AM
Points: 2,390, Visits: 2,281
Olga B (9/13/2011)
Ah yes, my "favorite" bit of SQL syntax

select 0 [A]

A fun bug to find when I accidentally delete a comma and then try to figure out what's wrong with the output of

select col1
col2,
col1003
from sometable

What? I can't be the only one!

Thanks for the question!

My favorite syntax is
select col1 AS [newcolname/sometime user friendly col name]
from sometable

Other syntax is less readable and as you wrote it may lead to unwanted bug. But maybe very usefull for code generators.
Post #1174701
Posted Wednesday, September 14, 2011 12:36 PM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Tuesday, December 10, 2013 4:26 PM
Points: 582, Visits: 451
Carlo - absolutely that is confusing. When I intend to alias the column, I prefer to use [ColumnName] = col1 syntax, which aligns all my column names nicely.

The problem arises when I lose the comma by accident, and SQL turns col2 into an alias for col1, thus messing up my output.
Post #1175202
Posted Friday, March 02, 2012 3:06 PM
SSC-Addicted

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

Group: General Forum Members
Last Login: Tuesday, February 11, 2014 9:09 AM
Points: 483, Visits: 242
Interesting question and took quite sometime to figure out and also learnt along the way.

Thank you.
Post #1261058
« Prev Topic | Next Topic »

Add to briefcase «««123

Permissions Expand / Collapse