Search code examples
sql-server-2008stored-procedurespython-2.6call-graph

Is there a free tool which can help visualize the logic of a stored procedure in SQL Server 2008 R2?


I would like to be able to plot a call graph of a stored procedure. I am not interested in every detail, and I am not concerned with dynamic SQL (although it would be cool to detect it and skip it maybe or mark it as such.)

I would like the tool to generate a tree for me, given the server name, db name, stored proc name, a "call tree", which includes:

  • Parent stored procedure.
  • Every other stored procedure that is being called as a child of the caller.
  • Every table that is being modified (updated or deleted from) as a child of the stored proc which does it.

Hopefully it is clear what I am after; if not - please do ask. If there is not a tool that can do this, then I would like to try to write one myself. Python 2.6 is my language of choice, and I would like to use standard libraries as much as possible. Any suggestions?

EDIT: For the purposes of bounty Warning: SQL syntax is COMPLEX. I need something that can parse all kinds of SQL 2008, even if it looks stupid. No corner cases barred :)

EDIT2: I would be OK if all I am missing is graphics.


Solution

  • **I just realized you might be looking for a Python library that can do this for you. If so, I apologize for the dud answer lol, but if you're trying to visualize a DB so you can perform maintenance, then my answer is the same :) **

    It's not free, but I assure you SQL Dependency Tracker from RedGate is well worth the money. It produces a graph like you're describing, allowing you to see all the participants in every procedure, key, view, trigger, etc. Awesome software: http://www.red-gate.com/products/sql-development/sql-dependency-tracker/

    I know you said free, but I was in the same boat as you several years ago and looked quite a bit for something that could do the job, free or not. Until I found this software, nothing else could do what I needed. I strongly encourage you to find the money for this tool if you need to do this sort of thing on a regular basis.