I'm trying to use visual studio code to search our code base for SQL statements table declarations are missing the schema using a regex expression.
So far I've got this
(from|inner join|left join)((\s|\r|\r\n)*)(dbo|sys)
which selects where the schema is included, but I'm having trouble excluding where the schema (or table name) is not dbo
or sys
e.g. "Select * from company" should be found, where "Select * from dbo.company" should not.
I though it would be
(from|inner join|left join)((\s|\r|\r\n)*)(!dbo|!sys)
but that selects nothing.
and I'm aware this misses APPLY
s, INSERT
s, etc.