Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 753
Hamish Grubijan Avatar asked Dec 14 '10 22:12

Hamish Grubijan


People also ask

How do I view a stored procedure in SQL Server?

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.

Which stored procedure helps in viewing the details of any user-defined stored procedure?

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.

Can we write view in stored procedure?

You can't create a view from a stored procedure.


1 Answers

**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.

like image 153
Brett Rossier Avatar answered Oct 07 '22 01:10

Brett Rossier