user1034912 user1034912 - 6 months ago 21
SQL Question

Why does this SQL ODBC query not work?

How come this SQL Statement doesn't work?

Select 'event2' as 'EVENTCOLN'


The error comes out as:

[Honeywell][ODBC Driver]Expected lexical element not found:

If I try

Select 'event2'


The error comes out as:

[Honeywell][ODBC Driver]Unexpected end of SQL statement

I have tried many other variations all doesn't seem to work.

I just want the database to spit out a value 'event2'

FYI, i'm connecting to an ODBC Driver called 'Experion PKS ODBC Driver'

Thanks

Answer

Try

Select 'event2' as EVENTCOLN

or

Select 'event2' as "EVENTCOLN"

You're using a string literal as a column name.

If your ODBC driver doesn't support selecting values without a table name, select a random table and select the TOP 1:

SELECT TOP 1 'event2' AS EVENTCOLN FROM MyTable