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
  • 314,254
  • 77
  • 507
  • 490
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
  • 128,762
  • 24
  • 200
  • 224
0

Try:

SELECT [Sysdate] FROM table1;
Dave Markle
  • 92,195
  • 20
  • 143
  • 169