SqlAltType%

Returns the SQL Server datatype of a compute column.

Syntax

SqlAltType% ( sqlconn%, computeid%, column% )

where

sqlconn%
Is a SQL Server connection. The value of sqlconn% is returned by SqlOpen%.
computeid%
Is the COMPUTE clause. A SELECT statement can have multiple COMPUTE clauses, which can have varying numbers of aggregate operators and aggregate targets. The computeid% is returned by SqlNextRow% or SqlGetRow%.
column%
Is the number of the column. The first column returned is number 1.

Returns

The type of data in a column in the COMPUTE clause, as follows:

Column
datatype

Returned constant
char SQLCHAR
varchar SQLCHAR
binary SQLBINARY
varbinary SQLBINARY
tinyint SQLINT1
smallint SQLINT2
int SQLINT4
real SQLFLT4
float SQLFLT8
smallmoney SQLMONEY4
money SQLMONEY
decimal SQLDECIMAL
numeric SQLNUMERIC
smalldatetime SQLDATETIM4
datetime SQLDATETIME
image SQLIMAGE
text SQLTEXT

Call SqlAltType% only after SqlNextRow% or SqlGetRow% returns a computeid.

If either the computeid% or the column% is invalid, - 1 is returned.

Remarks

SqlAltType% returns the datatype in a particular column in a COMPUTE clause. In the following example, SqlAltType%(sqlconn%, 1, 1) returns the type for SQLINT4 because the counts are of sqlint4 datatype.

select dept, name from employee
order by dept, name
compute count(name) by dept

To convert the type to a readable string, use SqlPrType$.

See Also

SqlAData$, SqlADLen&, SqlAltLen%, SqlGetRow%, SqlNextRow%, SqlNumAlts%, SqlPrType$; DB-Library for Visual Basic Options.