Skip to content

SQL Server (T-SQL) Keyword Compatibility Reference

Generated for GSP Java version 4.1.0.8 on 2026-03-15

This page was generated using hybrid static extraction from parser source files combined with runtime validation against the actual GSP parser. Re-run the extraction script after parser updates to keep this page current.

Keyword-as-Column-Name Support

As of version 4.1.0.8, the GSP SQL Server parser includes a lexer lookahead mechanism that allows 5 vendor-unreserved keywords to be used as unquoted column names in SELECT statements.

The lookahead pre-scans the token list before parsing and converts context-specific keywords to identifiers when they appear in column-name position:

  • After: SELECT, ,, DISTINCT, or ALL
  • Before: FROM, AS, WHERE, GROUP, ORDER, HAVING, LIMIT, UNION, INTERSECT, EXCEPT, INTO, ,, ), or ;
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
-- Works: keyword as column name
SELECT case FROM t;

-- Works: keyword as column name
SELECT next FROM t;

-- Works: keyword as column name
SELECT parse FROM t;

-- Original keyword syntax also still works

Full Classification Overview

Out of 586 keywords recognized by the GSP SQL Server parser:

Classification Count Description
Allowed 537 Can be used as an unquoted column name in both canonical contexts
Context-specific 7 Fails as SELECT keyword FROM t but works as SELECT t.keyword FROM t
Blocked 42 Cannot be used as an unquoted column name in either context

Context-Specific Keywords (7)

These keywords fail when used as bare column names (SELECT keyword FROM t) but succeed when table-qualified (SELECT t.keyword FROM t).

Keyword Reason
ALL SELECT qualifier
CASE Expression keyword
DISTINCT SELECT qualifier
NEXT Grammar keyword
PARSE Grammar keyword
TOP SELECT qualifier
UNION Clause keyword

Blocked Keywords (42)

These keywords cannot be used as unquoted column names in either context.

Keyword Workaround
BREAK SELECT "break" FROM t
CHECKPOINT SELECT "checkpoint" FROM t
CLOSE SELECT "close" FROM t
COMMIT SELECT "commit" FROM t
CONTINUE SELECT "continue" FROM t
DBCC SELECT "dbcc" FROM t
DEALLOCATE SELECT "deallocate" FROM t
DECLARE SELECT "declare" FROM t
DELETE SELECT "delete" FROM t
DENY SELECT "deny" FROM t
EXEC SELECT "exec" FROM t
EXECUTE SELECT "execute" FROM t
FETCH SELECT "fetch" FROM t
FROM SELECT "from" FROM t
GOTO SELECT "goto" FROM t
GRANT SELECT "grant" FROM t
IF SELECT "if" FROM t
INSERT SELECT "insert" FROM t
KILL SELECT "kill" FROM t
MERGE SELECT "merge" FROM t
OPEN SELECT "open" FROM t
PRINT SELECT "print" FROM t
RAISERROR SELECT "raiserror" FROM t
READTEXT SELECT "readtext" FROM t
RECONFIGURE SELECT "reconfigure" FROM t
RETURN SELECT "return" FROM t
REVERT SELECT "revert" FROM t
REVOKE SELECT "revoke" FROM t
ROLLBACK SELECT "rollback" FROM t
SAVE SELECT "save" FROM t
SELECT SELECT "select" FROM t
SET SELECT "set" FROM t
SETUSER SELECT "setuser" FROM t
SHUTDOWN SELECT "shutdown" FROM t
THROW SELECT "throw" FROM t
UPDATE SELECT "update" FROM t
UPDATETEXT SELECT "updatetext" FROM t
USE SELECT "use" FROM t
WAITFOR SELECT "waitfor" FROM t
WHERE SELECT "where" FROM t
WHILE SELECT "while" FROM t
WRITETEXT SELECT "writetext" FROM t

Workaround: Double-Quoted Identifiers

For any keyword that fails as an unquoted column name, you can use double-quoted identifiers:

1
2
3
4
5
-- Blocked or context-specific keyword as column name
SELECT "break" FROM t;

-- Or use table qualification for context-specific keywords
SELECT t.all FROM t;

Scope and Limitations

  • Tested contexts: SELECT keyword FROM t and SELECT t.keyword FROM t. Other contexts (DDL column definitions, INSERT column lists, aliases) may behave differently.
  • Version-specific: This report reflects GSP Java version 4.1.0.8.
  • Case sensitivity: Keywords are case-insensitive. select, SELECT, and Select are all treated the same.

How to Report Discrepancies

If you encounter a keyword that behaves differently from what this page describes, please report it through your support channel. Include:

  1. The exact SQL statement
  2. The GSP parser version
  3. Whether the same SQL works in SQL Server

Methodology

  1. Static extraction: A Python script parses the lexer (.cod) and grammar (.y) source files to identify all 586 keywords and their grammar classifications.
  2. Runtime validation: A Java test harness validates every classification against actual TGSqlParser runtime behavior.
  3. JSON dataset: The authoritative data is stored in docs/generated/mssql_keyword_compatibility.json.