September 16, 2010 at 7:34 am
Was wondering if anyone had any recommended programs or scripts for documenting database code. Specifically, I'd like the documentation to be in HTML format. I'd also really like something that will tell me what the result set for a stored procedure or table-valued function will be (if this is even possible).
September 16, 2010 at 7:55 am
sqldoc is one of the tool from redgate.
----------
Ashish
September 16, 2010 at 8:08 am
j take a look at this thread from a week or so ago; there is a script contribution that I enhanced and fixed slightly;
http://www.sqlservercentral.com/Forums/Topic981671-149-1.aspx#bm981831
it produces well formatted, informative html document.
I've taken that script and enhanced it to my own needs, but it's an awesome documentation starting point. I've got an even more enhanced version that also includes the table CREATE TABLE DDL definitions and the proc/view/function scripts in it as well.
here's a link to the results after pointing it against my master database(which has a lot of user objects, but that's another issue entirely)
master_db_documentation.html[/
Lowell
September 16, 2010 at 8:14 am
I ran the script and it does what you said it would. Very nice. I have used the BIDocumentor tool because it goes down to the column level, you can click a column name and find every object where it is used.
This kind of documentation or anykind of documentation is what most shops need and don't have available.
Thanks again for the script.
Nancy
September 16, 2010 at 8:38 am
J i poked around, and did nto find a way to get the output of the columns/structure of a stored procedure (if it returns result set) so far;
if we can find a way to do that, i could help adding that section to that script example...assuming it's even close to what you are after.
Lowell
September 16, 2010 at 9:04 am
I found a way, but I'm having trouble getting it to work.
DECLARE @nvQueryRemote nvarchar(MAX)
DECLARE @nvQueryLocal nvarchar(MAX)
SET @nvQueryRemote = N'SET FMTONLY ON; EXEC iERP81GA_LIVE.vmfg.uspGetAllLocSalesOrder'
SET @nvQueryLocal = N'SELECT * FROM OPENROWSET(''SQLOLEDB'', ''SERVER=(local);Trusted_Connection=Yes'',
''' + @nvQueryRemote + N''')'
PRINT @nvQueryLocal
EXEC (@nvQueryLocal)
This is just the framework, I'd actually want to SELECT * INTO <temp table> FROM OPENROWSET, but I keep getting an error:
Msg 7357, Level 16, State 1, Line 1
Cannot process the object "SET FMTONLY ON; EXEC iERP81GA_LIVE.vmfg.uspGetAllLocSalesOrder". The OLE DB provider "SQLNCLI" for linked server "(null)" indicates that either the object has no columns or the current user does not have permissions on that object.
Note that running just the command "SET FMTONLY ON; EXEC iERP81GA_LIVE.vmfg.uspGetAllLocSalesOrder" works fine.
September 16, 2010 at 9:11 am
my snippets have an open query example slightly different;
i know i've used this to insert into a local temp table
SELECT *
INTO #tmp
FROM OPENROWSET('SQLOLEDB','Server=yourservernamehere;Trusted_Connection=Yes;Database=Master',
'Set FmtOnly OFF; EXEC dbo.sp_Who')
Lowell
September 16, 2010 at 9:20 am
Alright, I guess that's not working for stored procedures that run against another linked server. So I guess that solution won't work. Wonder how BIDS does it... maybe I'll profile it and find out.
September 16, 2010 at 3:08 pm
All I'm getting from the profiler is that it's actually executing the stored procedure. Apparently BIDS is getting the field names by executing the script programmatically, and there doesn't appear to be any way to get this information from T-SQL.
EDIT: The method above does work for some scripts, but I'm thinking anything with an EXEC or something similar will not work.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply