MSSQL Server 2005 - select [field] AS [name] does not work?

"[email protected]" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <CAHdosDpi4VjEm6q-Gh0TenLdk2hGaX+bO0S6xpbr11=Prv8hkw@mail.gmail.com>
I have a unix server which has PHP 5.2.13 installed, and it has access to
two SQL servers (one is running MSSQL SERVER 2000 and the other MSSQL 2005).

It uses FreeTDS - details:

   - Version: freetds v0.91
   - freetds.conf directory: /usr/local/etc
   - MS db-lib source compatibility: no
   - Sybase binary compatibility: no
   - Thread safety: yes
   - iconv library: yes
   - TDS version: 7.1
   - iODBC: no
   - unixodbc: yes
   -
   - SSPI "trusted" logins: no
   - Kerberos: no

And I'm using unixODBC-2.3.1

The MSSQL 2000 server is fine, I can run all SQL statements and use
mssql_num_rows and mssql_fetch_assoc much as you would with MySQL.

However, the MSSQL 2005 server won't work with mssql_num_rows or
mssql_fetch_assoc - you have to use odbc_fetch_row.

That's not really an issue, I assume it's just due to the different server
installs.

However, I have a huge issue with the MSSQL 2005 server connection: I
cannot select a field AS another name!

For example:

SELECT
   [EnquiryID] AS "The_Key"
   FROM [db].[dbo].[table]

Works fine in my admin application (ie: NOT PHP), but if I run the same in
my PHP environment, I get:

stdClass Object
(
    [PK_EnquiryID] => 1
)

You can see it should be [The_Key] => 1

Has anyone any idea how we can get round this, please? I'm tearing my hair
out!

Cheers

Neil
---
www.hencam.co.uk - for when you really want to watch hens on the Internet...
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.