11:11 AM
@PeterVandivier I've been chipping away at this for a while, off and on. Stored procs are trickier if you allow for deferred name resolution (but there's a DMV for that, too).
If you want to cheat just dump it all into a graph using the node & edge tables, and perform a topological sort. Simples!
There are C# classes which parse T-SQL. So one could, if sufficiently motivated, trace a complete code path from INSERT through triggers, SP parameters, local variables and temp tables etc. for a total data lineage or code change impact analysis.