SqlColLen%

Returns the maximum length, in bytes, of the data in a column.

Syntax

SqlColLen% ( sqlconn%, column% )

where

sqlconn%
Is a SQL Server connection. The value of sqlconn% is returned by SqlOpen%.
column%
Is the number of the column. The first column is number 1.

Returns

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.

Remarks

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.

Example

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

See Also

SqlColName$, SqlColType%, SqlData$, SqlDatLen&, SqlNumCols%