In the end I use following regex with
$regex = '#(FROM)\s+((?!\.)[[:alnum:]_]+)\s+(\w*)\s*(INNER|LEFT|WHERE|\))#i'; $regex2 = '#(JOIN)\s+((?!\.)[[:alnum:]_]+)\s+(\w*)\s*(ON)#i';
I've thousand of queries I need to execute from a text file.
See bellow a kind of query I have:
SELECT * FROM T1 A INNER JOIN DB2.dbo.CI_T1 B ON A.id= B.id LEFT OUTER JOIN T3 C ON B.id = C.id WHERE ...
Some of tables are well named (
database.owner.table_name), and some other no (
How can I use a regex to update each query to replace unqualified instances of