﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Discuss Content Posted by Robert Marda / Article Discussions / Article Discussions by Author  / Documenting Stored Procedures / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 21 May 2013 06:33:25 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Documenting Stored Procedures</title><link>http://www.sqlservercentral.com/Forums/Topic17195-76-1.aspx</link><description>Here is one more [url=http://pragmaticworks.com/Products/Business-Intelligence/BIDocumenter/Overview.aspx]Free Tool to document Sql Server Database[/url]</description><pubDate>Mon, 02 May 2011 11:57:42 GMT</pubDate><dc:creator>SSIS Guy</dc:creator></item><item><title>RE: Documenting Stored Procedures</title><link>http://www.sqlservercentral.com/Forums/Topic17195-76-1.aspx</link><description>Good question. I'd also like to know that...</description><pubDate>Tue, 21 Jul 2009 08:06:37 GMT</pubDate><dc:creator>jumpin</dc:creator></item><item><title>RE: Documenting Stored Procedures</title><link>http://www.sqlservercentral.com/Forums/Topic17195-76-1.aspx</link><description>These are great ideas when creating/update SPs.How about the problem of existing SPs - getting a list of parms, keys, etc. that already exist but are undocumented as noted in the article?  Are there any tools or tricks to getting this information w/o touching every SP manually?</description><pubDate>Wed, 17 Dec 2008 14:31:35 GMT</pubDate><dc:creator>karchem</dc:creator></item><item><title>RE: Documenting Stored Procedures</title><link>http://www.sqlservercentral.com/Forums/Topic17195-76-1.aspx</link><description>&lt;P&gt;RAISERROR is the way to go if you are going to throw an error up the chain. &lt;/P&gt;&lt;P&gt;At the very least if you are using RETURN you should be giving RETURN a value so that your calling EXEC knows there was a failure.&lt;/P&gt;&lt;PRE&gt;CREATE PROC dbo.myBad   @myInt    int    = 0AS   IF @myInt = 0       RETURN 1    --- @myInt can't be 0GO&lt;/PRE&gt;&lt;PRE&gt;DECLARE @myResult intEXEC @myResult = dbo.myBadIF @myResult &amp;lt;&amp;gt; 0BEGIN -- Error handling routine    PRINT 'There was an error'    .....END&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;</description><pubDate>Wed, 20 Oct 2004 23:40:00 GMT</pubDate><dc:creator>Julian Kuiters</dc:creator></item><item><title>RE: Documenting Stored Procedures</title><link>http://www.sqlservercentral.com/Forums/Topic17195-76-1.aspx</link><description>&lt;P&gt;Your's example code:&lt;/P&gt;&lt;P&gt;It's better to use statements like :&lt;/P&gt;&lt;P&gt;  if @parameter is null ....&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;SP parameters can be obtained from metadirectory&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Uneeded and espesially not current comments are wost then none!!! &lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description><pubDate>Wed, 20 Oct 2004 09:52:00 GMT</pubDate><dc:creator>leslaw</dc:creator></item><item><title>RE: Documenting Stored Procedures</title><link>http://www.sqlservercentral.com/Forums/Topic17195-76-1.aspx</link><description>&lt;P&gt;I prefer to add my comments after the create procedure, eg&lt;/P&gt;&lt;P&gt;create proc rpcNameOfProc   @AcctMonthEndDate datetimeas&lt;/P&gt;&lt;P&gt;--Custom script created for Client--This script should be reinstalled and tested at time of an upgrade.--Name - rpcNameOfProc--Version - 4--Author - Gareth Mercer--Create Date - 20 October 2004--Description - Used for the report Report.rpt&lt;/P&gt;&lt;P&gt;That way when you're at a client's and you want to know what version they have, you can do ansp_helptext, rather than rely on the client to have a record.&lt;/P&gt;</description><pubDate>Tue, 19 Oct 2004 23:21:00 GMT</pubDate><dc:creator>merceroz</dc:creator></item><item><title>RE: Documenting Stored Procedures</title><link>http://www.sqlservercentral.com/Forums/Topic17195-76-1.aspx</link><description>Good article, but I have only one disagreement.  Instead of PRINT statements, I prefer to use RAISERROR.  With RAISERROR, you can pass in variables to make the error message descriptive, plus it actually produces an error, which can be caught and rethrown by the calling procedure if necessary.  Example:&lt;pre id=code&gt;&lt;font face=courier size=2 id=code&gt;CREATE PROC MyProc1  @LastName VARCHAR(30) = '', @FirstName VARCHAR(30) = ''AS  IF @LastName = '' OR @FirstName = '' BEGIN    RAISERROR('MyProc1 expects both parameters @FirstName and @LastName.  Both are VARCHAR(30).  Values supplied were @LastName: %s and @FirstName: %s', 16, 1, @LastName, @FirstName)  END...&lt;/font id=code&gt;&lt;/pre id=code&gt;Just my 2 cents. </description><pubDate>Tue, 21 Oct 2003 07:37:00 GMT</pubDate><dc:creator>jpipes</dc:creator></item><item><title>RE: Documenting Stored Procedures</title><link>http://www.sqlservercentral.com/Forums/Topic17195-76-1.aspx</link><description>I liked the article, especially the description of how to put in the informative directions using the PRINT command. I'm going to go through my sp's and see where I can use that.-SQLBill*If you're not learning something every day - you are asleep or just dead. </description><pubDate>Mon, 20 Oct 2003 11:27:00 GMT</pubDate><dc:creator>SQLBill</dc:creator></item><item><title>RE: Documenting Stored Procedures</title><link>http://www.sqlservercentral.com/Forums/Topic17195-76-1.aspx</link><description>Its not exactly 'documentation' but ... Don't forget the ability of VSS or your source control system to use keywords to keep the basic date/time last changed info up to date.  As someone who moves procs around, having this header helps me quickly see what is in production and in test (see below for my basic header)./*---------------------------------------------$Logfile: $$Revision: $$Date: $---------------------------------------------*/As far as internal/external documentation ... the internal stuff helps you understand the actual functioning of the object, but good external documentation helps you understand the overall system.And don't forget consistant standards in naming objects and variables.  That assists better than volumes of text in "getting it". </description><pubDate>Mon, 20 Oct 2003 10:55:00 GMT</pubDate><dc:creator>rawheiser</dc:creator></item><item><title>RE: Documenting Stored Procedures</title><link>http://www.sqlservercentral.com/Forums/Topic17195-76-1.aspx</link><description>Nice summary of items. Personally I usually set parameters to NULL and then check for NULL to display the "you need parameter x" included" message.I'm wary of external documentation. People get too busy and this is difficult to keep up with, so I don't recommend it. Instead, I prefer to keep any notes, docs, etc. in the proc. Still searching for a good way to provide this to new people, but I think it needs to be kept with the code.Steve Jonessjones@sqlservercentral.comhttp://www.sqlservercentral.com/columnists/sjonesThe Best of SQL Server Central.com 2002 - http://www.sqlservercentral.com/bestof/www.dkranch.net</description><pubDate>Mon, 20 Oct 2003 10:44:00 GMT</pubDate><dc:creator>Steve Jones - SSC Editor</dc:creator></item><item><title>RE: Documenting Stored Procedures</title><link>http://www.sqlservercentral.com/Forums/Topic17195-76-1.aspx</link><description>If you're going to be generating external documentation (which some internal/external clients like) then the data dictionary can be used to great effect to streamline your process.  Even a relatively simple SELECT statement against SYSCOMMENTS can extract the "Basic Comment" at the begining of every procedure.  You could then XML-&amp;gt;XSL that output to word as HTML or use PRINT statements to output it to word as cut and paste.Generally though, I feel that such documentation is not worth any effort, even as rapid a process as this one.Steven </description><pubDate>Mon, 20 Oct 2003 09:55:00 GMT</pubDate><dc:creator>ensslen</dc:creator></item><item><title>RE: Documenting Stored Procedures</title><link>http://www.sqlservercentral.com/Forums/Topic17195-76-1.aspx</link><description>One thing I always try to do is add a comment at the start of a "programming block" -- BEGIN, IF, ELSE, WHILE.  It really helps when reviewing code to have a quick comment on what's going on in this IF block, or what occurs in each iteration of the WHILE loop.Here's an outline.  (Please note that I do indent my code; I've yet to figure out how to get this forum to accept leading spaces on new paragraphs.)&lt;font face='Courier New'&gt;IF &amp;lt;someCondition&amp;gt; BEGIN    --  Description of conditions causing this IF code to run ENDELSE BEGIN    --  Description of conditions causing this ELSE code to run (very useful if the IF clause is fifty lines back) ENDENDIF&lt;/font id='Courier New'&gt;&lt;font face='Georgia'&gt;&lt;/font id='Georgia'&gt;&lt;font face='Impact'&gt;&lt;/font id='Impact'&gt; </description><pubDate>Mon, 20 Oct 2003 08:40:00 GMT</pubDate><dc:creator>Philip Kelley</dc:creator></item><item><title>Documenting Stored Procedures</title><link>http://www.sqlservercentral.com/Forums/Topic17195-76-1.aspx</link><description>Comments posted to this topic are about the content posted at &lt;A HREF=http://www.sqlservercentral.com/columnists/rmarda/documentingstoredprocedures.asp&gt;http://www.sqlservercentral.com/columnists/rmarda/documentingstoredprocedures.asp&lt;/A&gt;</description><pubDate>Sun, 12 Oct 2003 00:00:00 GMT</pubDate><dc:creator>Robert W Marda</dc:creator></item></channel></rss>