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 开发者_如何学Goa 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.
**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.
You can use SQL Server Management Studio to show the actual or estimated query plan. It gives a graphical output that you can follow. Here's a little primer: http://www.mssqltips.com/tip.asp?tip=1873
Update:
You can use SQL Server Integration Services (SSIS) to create data extracts in a graphical fashion. You can also use Microsoft Biztalk Server to create complex graphical layouts that also extract data. Finally, you can use Microsoft's WF to create automated processes in a graphical fashion that can do similar functions as Biztalk. Alas, these aren't free :(. If you have a MSDN subscription they are :)
Biztalk Map: http://geekswithblogs.net/images/geekswithblogs_net/Chilberto/WindowsLiveWriter/BizTalkMapComparisonbetweenTableLoopinga_B5B9/image_6.png
SQL Negotiator Pro has a free lite version at www.aphilen.com The full version is the only product out there that will find all dependencies and not stop after finding the first 10 child dependencies. Other products fail when there is a circular reference and just hang, these guys have covered this off. Also a neat feature is the ability to add notes to the diagram so that it can be easily distributed. Full version is not cheap but has saved us plenty of hours usually required figuring out complex database procedures. apex also provide a neat tool
精彩评论