SqlTabCount%

Returns the number of tables included in the current SELECT statement.

Syntax

SqlTabCount% ( sqlconn% )

where

sqlconn% ( )
Is a SQL Server connection. The value of sqlconn% is returned by SqlOpen%.

Returns

The number of tables, including SQL Server work tables, included in the current SELECT statement. If an invalid sqlconn% value is sent to SqlTabCount%, a value of -1 is returned.

Remarks

SqlTabCount% is a DB-Library for Visual Basic browse-mode function. For a detailed discussion of browse mode, see DB-Library for Visual Basic Programming.

A SELECT statement can generate a set of result rows whose columns are derived from several database tables. To perform browse-mode updates of the columns in a statement's select list, your application must know how many tables are involved in the query, because each table requires a separate UPDATE statement. SqlTabCount% can provide this information for ad hoc queries. When a query is hard-coded into the application, SqlTabCount% is unnecessary.

The count returned by SqlTabCount% includes any SQL Server work tables used in processing a query. SQL Server sometimes creates temporary internal work tables to process a query and deletes them by the time it finishes processing the statement. Work tables cannot be updated and are not available to your application. Therefore, design your application such that before it uses a table number, it verifies that the number does not belong to a work table. SqlTabName$ can be used to determine whether a particular table number refers to a work table.

You can call SqlTabCount% any time after you call SqlResults%.

See Also

SqlColBrowse%, SqlColSource$, SqlQual$, SqlTabBrowse%, SqlTabName$, SqlTabSource$, SqlTsNewLen%, SqlTsNewVal$, SqlTsPut%