How to get the value type returned from the SQL_VARIANT column (db-lib)

Sergey Pashkov <[email protected]> Fri, 17 Nov 2017 12:26:22 +0200
Newsgroups gmane.comp.db.tds.freetds
Message-ID <CAOAvatyTt3Xse6yg0u969Eh-nvjmpq8s4d-cuqxyE7-NaOJTNA@mail.gmail.com>
Hello,

I'm using:
1) db-lib freetds-1.00.70, on macOS
2) SQL Server 2017 on Linux

TDS protocol is set to 7.2

Here's a sample table:
CREATE TABLE t1( f1 SQL_VARIANT );
INSERT INTO t1 VALUES( 'string' );
INSERT INTO t1 VALUES( 55 );

I retrieve the data from this table
SELECT * FROM t1;

BYTE* msData = dbdata( hnd, i + 1 );
msData points to correct data - string and number respectively.

But how can I get the type of this data? Is it possible at all?

I can see internally it is stored in the TDSVARIANT structure, but dbdata
returns just the data.

Thank you!

--
Best regards,
Sergey Pashkov