Returns the SQL Server datatype for a result column.
SqlColType% ( sqlconn%, column% )
where
An integer value for the datatype of a specified column. If the column number is not in range, -1 is returned.
These are the returned values:
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 |
The SqlColType% function returns an integer value for the type. Use SqlPrType% to convert the type value into a readable string. This function cannot determine whether a column allows null values.
'Put the statement into the command buffer. cmd$ = "SELECT name, id, type FROM sysobjects" Result% = SqlCmd%(Sqlconn%, cmd$) 'Send the statement to SQL Server and start execution. Result% = SqlExec%(Sqlconn%) 'Process the statement results. Result% = SqlResults%(Sqlconn%) 'Print the column type. FOR ColumnNum% = 1 TO 3 ColumnType% = SqlColType%(Sqlconn%, ColumnNum%) PRINT "Column"; ColumnNum%; " type is"; ColumnType% NEXT ColumnNum%
SqlColLen%, SqlColName$, SqlData$, SqlDatLen&, SqlNumCols%