SqlParse to detect column references

The Python project sqlparse will be used, to extract column references from database views SQL code.

A Python script SqlParser.py was created.

  • to read sql_modules_definition

  • to write the parsed view definition back into the repository database

see more details (and how to run): SqlParser.py

After parsing, the results are available in sqlparse.RepoObject_SqlModules - U

Some views and persistences on top of this table are build to extract column references:
You need to execute 2 persistence procedures after each import of the parsing results.
It’s a good idea to also execute repo.usp_main to use the parsed content.

EXEC [sqlparse].[usp_sqlparse]

Exec repo.usp_main;

Finally, column references are available in reference.RepoObjectColumn_reference_SqlModules - V

They will be combined with other column reference sources in reference.RepoObjectColumn_reference_union - V.

Properties Inheritance and Database documentation generator are also based on column references.