MS SQL: an occasional "Invalid object name" error on one table that exists

Applies to: MS SQL through the Clarion SQL driver, as reported; the thread names no Clarion or server version.

Problem

Very occasionally, on various PCs and with no pattern, a call fails with "Invalid object name

". It is always the same table, in one procedure only. The SELECT (a simple SELECT TOP (1) ... FROM LocationTracking WHERE ... ORDER BY DATED DESC, TIMED DESC) pasted into Management Studio worked and returned the expected rows. The error appeared only after going into another procedure before this one. An OPEN of the table just before the call gave "file is already open".

Solution

  1. Run trace.exe before entering the other procedure and read the end of the trace when the error happens; check whether the statement went to another database.
  2. If the statement is built by hand, check the quoting of the WHERE value (use the apostrophe, not a look-alike).
  3. Fully qualify the table, [DatabaseName].[SchemaName].[LocationTracking]: if the connection was lost, the statement is evaluated against the master database, which does not contain the table.
  4. What fixed it for the poster: the error came from the temporary results table the procedure wrote to, not from the database. He did not say what was wrong with that table.

Caveats

  • Steps 1 to 3 were suggestions; the poster judged a lost connection unlikely and did not report trying the qualified name.
  • The root cause inside the temporary results table was not found.

Today (2026)

Likely still sound as a method (trace, qualify the name, look at the other tables the procedure touches). Not re-tested.

Sources: Jeremy N. (Oct 2016, the question), Graham D., Liam (Oct 2016, Nov 2016) in softvelocity.clarion.databasedrivers.