0

screenshot of queries

While toiling on a report last friday, I noticed a column that returned "3" for every row even though the data in the table said otherwise. After squinting very hard at my sql, I noticed a typo in my select list that was causing the problem.

Why does the sql parser allow the sytax below? I would have thought that this would return an error, since the column "3Name" does not exist in the table.

Select 3Name from Employee
Teepeemm
  • 4,331
  • 5
  • 35
  • 58
  • Please include the software you are using to do this - this is not true of all flavors of SQL and even varies based on the sql client being used. – cmt Jan 08 '17 at 03:51
  • this was on microsoft sql server 2012 –  Jan 08 '17 at 03:53

1 Answers1

1

It is interpreted as SELECT 3 AS NAME and hence the result with Column 'Name' And value 3 for all the rows.

Jerry
  • 127
  • 1
  • 9