Re: AS clause in 8.0
"James K. Lowden" <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 27 Mar 2012 16:55:09 -0400 Richard Stevens <[email protected]> wrote: > It seems that somewhere between FreeTDS and PHP, it is determined > that if there is no function, then the column name could not possibly > need to be changed or aliased in the resultset. I don't know whether you're using db-lib or ODBC. I know for certain db-lib returns the aliased column name. An ODBC IRD contains both the real column name and the alias. If you're in that space, cf. SQL_DESC_LABEL in the IRD. According to Microsoft's documentation for SQLSetDescField, that field has, in order: 1. The alias name (e.g. "1 as FOO") 2. The column name if unaliased 3. Nothing (e.g. "min(FOO)") You can use bsqldb or bsqlodbc to display the metadata. $ bsqldb -v -S $S -U$U -P$P <<< \ "select name as foo from systypes where name = 'int' " bsqldb:183: Verbose operation enabled bsqldb:232: Query: select name as foo from systypes where name = 'int' bsqldb:206: dbsqlsend(): OK bsqldb:214: dbsqlok(): OK bsqldb:310: calling dbresults: OK Result set 1 Allocating buffers Allocating compute buffers Metadata col name source type size varies ------ ------------------------------ ------------------------------ --------------- ------ ------ 1 foo foo char 128 1 Data foo ------------- int Retrieving return status... none 1 rows affected Retrieving output parameters... none bsqldb:683: dbresults() returned NO_MORE_RESULTS (2) HTH. --jkl