简体   繁体   中英

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.

What version of IBM i?

This works fine on 7.1

SELECT IBMREQD as "alt name" FROM sysibm.sysdummy1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM