keif888 / SQLServerMetadata

SQL Server Metadata Toolkit
Microsoft Public License
82 stars 32 forks source link

sqlStatement.getTableNames() not returning all tables used if you identify insert statement with nested derived tables #36

Closed FrankSagt closed 2 years ago

FrankSagt commented 2 years ago

Hi @keif888
When the insert statement is identified, not all tables are returned when a derived-table is used. I only get two tables back, instead of 4.

I also took the example of Microsoft, with the same effect. Or show the SQL Script in attachment. SQLQuery1.sqlSample Insert Into.txt

https://docs.microsoft.com/de-de/sql/t-sql/statements/insert-transact-sql?view=sql-server-2017#v-inserting-data-returned-from-an-output-clause

Where is my mistake? Which classes do I have to use to analyze nested derived tables?

Vielen dank für deine Unterstützung .

Viele Grüße Frank Kreß

keif888 commented 2 years ago

The findIdentifiers(TableReference tableSource) method was not parsing the Merge statement. This has been fixed in the code base.