you could search for words that exist after "FROM" and "JOIN", right? and that should get the tables, regardless of the prefix?
I'm playing wiht a splitting with a delimited split, and joining it against itself to get the tables?
this seems to work:
create table #temp1 (query nvarchar(max))
insert into #temp1
values (' SELECT * FROM dbo.table1')
, (' SELECT col1, col23 FROM dbo.table2 a join dbo.table3 b on a.col1 = b.col1')
insert into #temp1
values (' SELECT * FROM table1')
, (' SELECT col1, col23 FROM table2 a join table3 b on a.col1 = b.col1')
SELECT * FROM #temp1
CROSS APPLY dbo.DelimitedSplit8K(query,' ') T1
CROSS APPLY dbo.DelimitedSplit8K(query,' ') T2
WHERE T1.ItemNumber + 1 = T2.ItemNumber
AND T1.Item IN('JOIN','FROM')
Lowell