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:
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.
Using SQL Server Management StudioExpand Stored Procedures, right-click the procedure and then select Script Stored Procedure as, and then select one of the following: Create To, Alter To, or Drop and Create To. Select New Query Editor Window. This will display the procedure definition.
The SYS. OBJECTS is a catalog view in SQL Server, and it contains a row to every user-defined, schema-scoped object created within a database, including stored procedure. Now to list all the stored procedures using SYS.
You can't create a view from a stored procedure.
**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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With