ehh
ehh

Reputation: 3480

Alias containing space in SQL using AS400 database

I have an SQL statement and I would like to have an alias with a space. For example:

SELECT item as Alternate Item from Items;

I tried different syntaxes but it fails.

SELECT item as "Alternate Item" from Items;
SELECT item as [Alternate Item] from Items;
SELECT item as {Alternate Item} from Items;

It works fine if I change the alias to Alternate for example which doesn't contain spaces.

I am running the sql using the following code:

DataSet dataset = new DataSet();
OdbcCommand command = new OdbcCommand(sql);
command.Connection = con.Connection;
OdbcDataAdapter adapter = new OdbcDataAdapter(command);
con.Open();
adapter.Fill(dataset); // At this line I get the following error

An unhandled exception of type 'System.Data.Odbc.OdbcException' occurred in System.Data.dll

The database is AS400.

Upvotes: 0

Views: 1222

Answers (1)

Charles
Charles

Reputation: 23803

What version of IBM i?

This works fine on 7.1

SELECT IBMREQD as "alt name" FROM sysibm.sysdummy1

Upvotes: 1

Related Questions