1
votes

I have a simple SQL that need to call RedShift through ODBC. The SQL is like this

SELECT id as Tag From SomeView

This just not working. It gives me the error

DataSource.Error: ODBC: ERROR [42601] [Amazon][Amazon Redshift] (30) Error occurred while trying to execute a query: [SQLState 42601] ERROR: syntax error at or near "'Tag'" LINE 1: Select id As Tag From SomeView

Details:
DataSourceKind=Odbc
DataSourcePath=dsn=Amazon Redshift ODBC DSN
OdbcErrors=Table

I tried

SELECT id as 'Tag' From SomeView
SELECT id Tag From SomeView
SELECT id 'Tag' From SomeView

None of them work. Only the one with no rename works.

SELECT id From SomeView

Why is that???

1

1 Answers

4
votes

Try

SELECT id "Tag" From SomeView

Tag is a reserved word in Redshift, if you like to use reserved words as column names or aliases you need to use delimited identifiers (double quotes).