Ok, I am trying to solve a customer problem (with one of or ODBC drivers). I see the problem here with:
SQL Server 2014 - 12.0.2000.8 (X64), Express Edition (64-bit) on Windows NT 6.3 <X64> (Build 9600)
I have a linked server to a ODBC source via MSDASQL, all works fine, but sp_columns_ex returns a empty result set. I have tried this with three of our drivers, and two Microsoft SQL Server drivers, with identical results. Looking at a ODBC trace of the server activity it connects, does a few SQLGetInfo's, then calls SQLGetTypeInfo and binds all 19 columns, then fetches all the rows, closed the statement down and stops. Never gets to a SQLColumns.
My suspiscion is that its sometihng coming back from the SQLGetTypeInfo result set that it doesnt like, but getting the same result with differebt drivers makes me think its not the driver. What I have noticed in the log is the following:
sqlservr 8e8-fb0 EXIT SQLBindCol with return code 0 (SQL_SUCCESS)
HSTMT 0x00000000026BD230
UWORD 3
SWORD -18 <SQL_C_ULONG>
PTR 0x000000000DD9E460
SQLLEN 8
SQLLEN * 0x000000000DD9E458 (0)
Column 3 is the size, and the length of 8 makes me think someone somewhere in microsoft code is trying to get a 8 byte integer back from a column, even though its a SQL_C_ULONG which is 4 bytes, and teh ODBC spec states that the length is ignored on fixed length types. Later in the same set of binds it does
sqlservr 8e8-fb0 ENTER SQLBindCol
HSTMT 0x00000000026BD230
UWORD 9
SWORD -18 <SQL_C_ULONG>
PTR 0x000000000DD9E7F0
SQLLEN 4
SQLLEN * 0x000000000DD9E7E8
With the length now a normal (but still ignored) 4 bytes. I have tried tweeking the driver to make it return a 8 byte value when the 8 bytes are requested and variations on this, nothing seems to make it happy.
Has anyone out there got sp_columns_ex to work via a linked ODBC connection on a 64 bit server?