Query Pilot Identifier Case

Identifier-case enforcement catches scripts that work on a case-insensitive SQL Server but fail after deployment to a case-sensitive server or database.

Choose an Identifier case mode in Query Pilot Options to set the editor default. A script can override that default with a portable Minion Exec Policy directive:

/* MINION EXEC POLICY
EnforceCase: Enforce
Server: CODECON
Database: Minion
*/

DECLARE @ServerName sysname = N'SQL01';

SELECT s.ServerName
FROM dbo.Servers AS s
WHERE s.ServerName = @ServerName;

The comment remains valid in SSMS, sqlcmd, and other SQL tools.

Modes

  • Warn: shows yellow squiggles and Messages entries, but permits execution.
  • Block: shows red squiggles and blocks execution until every mismatch is corrected.
  • Enforce: immediately replaces mismatched identifiers with declaration/catalog spelling. All replacements are one undoable editor change.

For compatibility, EnforceCase: true means Enforce and EnforceCase: false means Warn. New scripts should use the explicit mode names.

When EnforceCase is declared in Minion Exec Policy, Block and Enforce also require Server and Database directives in that same comment. Query Pilot fails the policy on the EnforceCase line until both are present. This prevents catalog-backed identifier validation from silently using the wrong server or database.

Warn does not require those directives. It can still report local declaration problems and warn that catalog validation is incomplete.

What Is Checked

  • Scalar variables and procedure/function parameters use the case from their declaration.
  • Temporary tables use the case from CREATE TABLE or SELECT INTO.
  • Table aliases use the case from the FROM or JOIN declaration.
  • Database, schema, table, view, procedure, and function names use SQL Server catalog spelling.
  • Qualified columns and unambiguous columns use catalog spelling.

Comments and string literals are ignored. SQL keywords are handled separately by Uppercase keywords.

Feedback And Execution

Live checking, the Check button, and Run use the same analyzer. Messages contain the expected spelling. Hover an identifier squiggle to see the exact mismatch. When a script contains an EnforceCase directive, its policy-margin mark and compact policy shield reflect the actual mismatch result rather than merely confirming that the directive parsed.

Local identifiers can be checked without a database connection. Catalog-backed identifiers use a five-minute metadata cache and only run when Query Pilot can resolve exactly one target server and one database. Catalog validation uses the USE database when present, otherwise the tab's single selected database. When no unambiguous catalog context exists, local identifiers are still checked and catalog identifiers are left unresolved rather than guessed.

If catalog metadata cannot be loaded, Check reports that validation is incomplete. Query Pilot does not treat an unavailable catalog as a successful full validation, but it also does not turn a metadata connection problem into an identifier-case mismatch. With no selected target, multiple selected targets, or no unambiguous database in the editor, Messages explicitly says that only local symbols were checked.

Scope Examples

This fails in Block or Enforce mode because the catalog source is missing:

/* MINION EXEC POLICY
EnforceCase: Enforce
*/

This passes the scope requirement and allows catalog-backed validation:

/* MINION EXEC POLICY
EnforceCase: Enforce
Server: CODECON
Database: Minion
*/

Related: Query Pilot and Minion Exec Policy.

Documentation revision: 01209461ED75809D