1

I have a column named Sysdate in several tables, which is causing SQL errors when I try to Select it. It works if "Sysdate" is enclosed in double-quotes, e.g.

SELECT "Sysdate" FROM table1

When I try to use aliases it causes syntax errors:

SELECT t1."Sysdate" FROM table1 AS t1

Please advise.

Thank you,

Max.

Meringros
  • 354
  • 4
  • 13
  • Related: http://stackoverflow.com/questions/1162381/how-do-i-escape-a-reserved-word-in-oracle – OMG Ponies Aug 18 '10 at 02:14
  • Wow, that was fast! I haven't even finished browsing reddit :) Thank you guys, I will test it and accept one of the answers. M.> – Meringros Aug 18 '10 at 02:34

3 Answers3

3

For what database? MySQL allows you to escape reserved keywords using backticks:

SELECT `sysdate` FROM TABLE1

In SQL Server, you use hard brackets:

SELECT [sysdate] FROM TABLE1

Oracle uses double quotes:

SELECT "sysdate" FROM TABLE1
OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
0

try this for sql server

SELECT [Sysdate] FROM table1

for MySQl this should work, those are back ticks btw

SELECT `Sysdate` FROM table1
SQLMenace
  • 132,095
  • 25
  • 206
  • 225
0

Try:

SELECT [Sysdate] FROM table1;
Dave Markle
  • 95,573
  • 20
  • 147
  • 170