Returns the maximum length, in bytes, of the data in a column.
SqlColLen% ( sqlconn%, column% )
where
The maximum length of the data in a specified column. If the column number is not within range of the maximum length of the data, SqlColLen% return -1.
SqlColLen% do not return the actual length of the data in a column, but rather the maximum length that the data can be. For the actual length of data in a column, use SqlDatLen&. Call SqlColLen% after SqlResults% returns SUCCEED.
The following code fragment uses SqlColLen% to return the maximum length of the data in the name, id, and type columns from the sysobjects table:
'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 lengths. FOR ColumnNum% = 1 TO 3 ColumnLen& = SqlColLen%(Sqlconn%, ColumnNum%) PRINT "Column"; ColumnNum%; " length is"; ColumnLen& NEXT ColumnNum%
Output:
Column 1 length is 30 Column 2 length is 11 Column 3 length is 2
SqlColName$, SqlColType%, SqlData$, SqlDatLen&, SqlNumCols%