Here's the Mermaid graph code representing the dependency tree from the sp_helpview output:
graph TD
%% Nodes (Views, Tables, Functions)
vew_pbc_nsrd_sma_offering((vew_pbc_nsrd_sma_offering))
fn_get_esg_scrns{{fn_get_esg_scrns<br>SQL Function}}
vew_fund_esg_screens((vew_fund_esg_screens))
fund_esg_screens[(fund_esg_screens)]
vew_esg_exp_data_src_scrn((vew_esg_exp_data_src_scrn))
esg_exp_data_src_scrn[(esg_exp_data_src_scrn)]
vew_fund_isg_attributes((vew_fund_isg_attributes))
fund_isg_attributes[(fund_isg_attributes)]
vew_fund_esg_attributes((vew_fund_esg_attributes))
fund_esg_attributes[(fund_esg_attributes)]
vew_fund_detail((vew_fund_detail))
fund_detail[(fund_detail)]
eg_vew_prtf((eg_vew_prtf))
preq_toplevel_fund[(preq_toplevel_fund)]
eg_vew_btcd((eg_vew_btcd))
trad_comm_dates[(trad_comm_dates)]
eg_vew_bfun((eg_vew_bfun))
fund[(fund)]
eg_vew_bfpt((eg_vew_bfpt))
fund_port_type[(fund_port_type)]
eg_vew_bfcr((eg_vew_bfcr))
fund_curncy[(fund_curncy)]
eg_vew_bfal((eg_vew_bfal))
fund_alias[(fund_alias)]
%% Edges (Dependencies)
vew_pbc_nsrd_sma_offering --> fn_get_esg_scrns
vew_pbc_nsrd_sma_offering --> vew_fund_isg_attributes
vew_pbc_nsrd_sma_offering --> vew_fund_esg_attributes
vew_pbc_nsrd_sma_offering --> vew_fund_detail
vew_pbc_nsrd_sma_offering --> eg_vew_prtf
vew_pbc_nsrd_sma_offering --> eg_vew_btcd
vew_pbc_nsrd_sma_offering --> eg_vew_bfun
vew_pbc_nsrd_sma_offering --> eg_vew_bfpt
vew_pbc_nsrd_sma_offering --> eg_vew_bfcr
vew_pbc_nsrd_sma_offering --> eg_vew_bfal
fn_get_esg_scrns --> vew_fund_esg_screens
fn_get_esg_scrns --> vew_esg_exp_data_src_scrn
vew_fund_esg_screens --> fund_esg_screens
vew_esg_exp_data_src_scrn --> esg_exp_data_src_scrn
vew_fund_isg_attributes --> fund_isg_attributes
vew_fund_esg_attributes --> fund_esg_attributes
vew_fund_detail --> fund_detail
eg_vew_prtf --> preq_toplevel_fund
eg_vew_btcd --> trad_comm_dates
eg_vew_bfun --> fund
eg_vew_bfpt --> fund_port_type
eg_vew_bfcr --> fund_curncy
eg_vew_bfal --> fund_alias
%% Styles (Optional, for better visualization)
classDef view fill:#f9f,stroke:#333,stroke-width:2px
classDef table fill:#bbf,stroke:#333,stroke-width:2px
classDef function fill:#ff9,stroke:#333,stroke-width:2px
class vew_pbc_nsrd_sma_offering,vew_fund_esg_screens,vew_esg_exp_data_src_scrn,vew_fund_isg_attributes,vew_fund_esg_attributes,vew_fund_detail,eg_vew_prtf,eg_vew_btcd,eg_vew_bfun,eg_vew_bfpt,eg_vew_bfcr,eg_vew_bfal view
class fund_esg_screens,esg_exp_data_src_scrn,fund_isg_attributes,fund_esg_attributes,fund_detail,preq_toplevel_fund,trad_comm_dates,fund,fund_port_type,fund_curncy,fund_alias table
class fn_get_esg_scrns function
How to use this Mermaid code:
-
Online Mermaid Renderer:
- Go to Mermaid Live Editor.
- Paste the above code into the editor.
- The graph will render automatically.
-
Markdown Files (e.g., GitHub README):
-
VS Code:
- Install the "Markdown Preview Mermaid Support" extension.
- Create a
.md file, paste the wrapped code, and preview.
Graph Legend:
- Oval Shapes (( )): Views (e.g.,
vew_pbc_nsrd_sma_offering)
- Hexagons {{ }}: SQL Functions (e.g.,
fn_get_esg_scrns)
- Rectangles [ ]: Tables (e.g.,
fund_esg_screens)
Visual Hierarchy:
vew_pbc_nsrd_sma_offering is at the top.
- Level -1 dependencies (views and the SQL function) branch out directly from it.
- Level -2 dependencies (mostly tables) are children of the Level -1 views.
- Level -3 dependencies are the final tables (
fund_esg_screens, esg_exp_data_src_scrn).
Why Mermaid?
- Text-based: Easy to version-control and generate programmatically.
- Dynamic Rendering: Updates automatically if your
sp_helpview output changes.
- Widely Supported: Works in GitHub, GitLab, Bitbucket, VS Code, and more.
Now, visualize this graph and you'll have a clear picture of how vew_pbc_nsrd_sma_offering depends on other database objects!
Tips for Large Graphs:
- Use
graph LR (left-to-right) instead of graph TD if the graph is too wide.
- Remove the styles (
classDef, class) if the graph is too complex.
- Focus on critical paths by temporarily hiding less important nodes.
Happy diagramming!