September 13, 2011 at 11:40 am
I think I may need eye glasses, I really had to look hard at the commas to differentiate them from periods... I almost chose the Incorrect Syntax error.
September 13, 2011 at 1:00 pm
My first opinion was: very exotic question far away from practical usage.
But later I changed my minds. Never thought about arithmetical operations in T-SQl work in such way. Thanks a lot.
September 13, 2011 at 1:21 pm
Nice question.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
September 13, 2011 at 2:56 pm
It's a nice and interesting question. Thanks.
September 13, 2011 at 4:02 pm
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!:ermm:
Thanks for the question!
September 13, 2011 at 4:30 pm
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
September 13, 2011 at 4:45 pm
Good puzzler - thanks. Nice coverage of different scenarios.
September 14, 2011 at 1:41 am
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.
September 14, 2011 at 1:56 am
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!:ermm:
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.
September 14, 2011 at 12:36 pm
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.
March 2, 2012 at 3:06 pm
Interesting question and took quite sometime to figure out and also learnt along the way.
Thank you.
Viewing 11 posts - 16 through 25 (of 25 total)
You must be logged in to reply to this topic. Login to reply