Skip to content

Support SQL Server table variables through shared table references - #2581

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:feat/sqlserver-table-variables
Sep 11, 2026
Merged

Support SQL Server table variables through shared table references#2581
manticore-projects merged 1 commit into
JSQLParser:masterfrom
minleejae:feat/sqlserver-table-variables

Conversation

@minleejae

Copy link
Copy Markdown
Contributor

SELECT columnName FROM @table and DML targeting a declared table variable fail to parse. Add a shared table-reference production for query sources and DML targets, and reuse the existing alias production for UPDATE's table/index-hint path.

Table references carry an explicit tableVariable flag while preserving existing Table-based APIs and visitor/deparser dispatch. Cloning preserves the flag, default catalog/schema qualification leaves local references alone, and TablesNamesFinder separates local variables from catalog tables while retaining them in findTablesOrOtherSources. Validation checks the SQL Server table-variable feature and skips catalog-table metadata lookups for these references.

Catalog-only grammar remains unchanged. This adds parsing and reference classification; declaration binding and table-variable column/type resolution are outside this change.

Validation: full Gradle check and Maven verify; SELECT/JOIN/CTE, INSERT, UPDATE, DELETE and MERGE roundtrips, existing DML models, metadata lookups, dialect validation, cloning/qualification, scalar variables, declarations and following statements, normal tables/index hints, and unsupported catalog-only forms.

Syntax reference: Microsoft table documentation.

Fixes #911.

@manticore-projects
manticore-projects merged commit 7bb6e1c into JSQLParser:master Sep 11, 2026
9 checks passed
@manticore-projects

Copy link
Copy Markdown
Contributor

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL Server table variables not supported | SELECT columnName FROM @table

2 participants