Some interesting, obscure (and absolutely useless) T-SQL syntax

/*
Writing ugly SQL Statements is an art. Today I’ve spent
a few minutes trying to break our parser as well as giving
a grill to SQL Server’s parser.
So here is some extra syntax that is not behaving as
I’d expect it to behave.
*/

select 1.a

— Yes, this is legal, surprise surprise it returns a
— table with a single column, a single row, the value
— is 1, the column name is “a” !

— So let’s push it a bit further:

select -1.a

/*
Works, the result is:
a
—————————————
-1
*/

select -1/2.[-1/2]

/*
Wow, this works too, and it gives me
-1/2
—————————————
-0.500000

So can I just put anything after the ?decimal? point?
*/

select 1.SomeString

/*
SomeString
—————————————
1
*/

— But then there are exceptions:
select 1.a, 1.e, 0.a

/*
a                                  a
———– ———————- —————-
1           1                      0.0
sa

1.e does not produce the alias (e for exponent???),
0.a seems to use float, so the value displayed is 0.0

It is a shame that you cannot use this with string literals.
Unless you want to torture your colleagues I reckon that
the above is absolutely useless. But if you have an idea why
the above works, and works the way it works, do let me know.

PS: the above syntax works on 2000,2005 and 2008.

  Andras
*/