<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Extract Stored Procedure Comments with TSQL</title>
	<atom:link href="http://www.youdidwhatwithtsql.com/extract-stored-procedure-comments-with-tsql/563/feed" rel="self" type="application/rss+xml" />
	<link>http://www.youdidwhatwithtsql.com/extract-stored-procedure-comments-with-tsql/563</link>
	<description>making DBAs everywhere curse!</description>
	<lastBuildDate>Fri, 10 Feb 2012 10:13:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Rhys</title>
		<link>http://www.youdidwhatwithtsql.com/extract-stored-procedure-comments-with-tsql/563/comment-page-1#comment-160</link>
		<dc:creator>Rhys</dc:creator>
		<pubDate>Thu, 06 May 2010 20:40:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.youdidwhatwithtsql.com/extract-stored-procedure-comments-with-tsql/563#comment-160</guid>
		<description>Cheers, differing commenting habits is a pain we have to live with. Thanks for your input.

Rhys</description>
		<content:encoded><![CDATA[<p>Cheers, differing commenting habits is a pain we have to live with. Thanks for your input.</p>
<p>Rhys</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: geographika</title>
		<link>http://www.youdidwhatwithtsql.com/extract-stored-procedure-comments-with-tsql/563/comment-page-1#comment-159</link>
		<dc:creator>geographika</dc:creator>
		<pubDate>Thu, 06 May 2010 06:55:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.youdidwhatwithtsql.com/extract-stored-procedure-comments-with-tsql/563#comment-159</guid>
		<description>Great stuff. I was looking to take comments that other developers had made in SPs and add them to the extended properties so RedGate&#039;s SqlDoc could use them for documentation. 
I used your code (with a few mods due to differing comment use) then added the following code at the end to set the extended properties:


-- Select all records in the #ProcDoc table
-- and replace line breaks with a space for better formatting 
DECLARE metaCursor CURSOR LOCAL FAST_FORWARD 
FOR SELECT [Schema],[Proc],REPLACE(cast([Description] as nvarchar(max)), CHAR(10), &#039; &#039;) FROM #ProcDoc;

OPEN metaCursor;
FETCH NEXT FROM metaCursor INTO @myschema,
				@myproc, @mydesc;
 
WHILE (@@FETCH_STATUS = 0)
	BEGIN

		-- Update MS_Description Extended property
		
	exec sp_executesql N&#039;if (SELECT count(*) 
	FROM ::fn_listextendedproperty (@propertyName, @myLevel0Type, @myLevel0Name, @myLevel1Type, @myLevel1Name, @myLevel2Type, @myLevel2Name))&gt; 0 
	begin 
		EXEC sp_updateextendedproperty  @propertyName, @propertyValue, @myLevel0Type, @myLevel0Name, @myLevel1Type, @myLevel1Name, @myLevel2Type, @myLevel2Name; 
	end 
	else 
	begin 
		EXEC sp_addextendedproperty @propertyName, @propertyValue, @myLevel0Type, @myLevel0Name, @myLevel1Type, @myLevel1Name, @myLevel2Type, @myLevel2Name; 
	end&#039;,
	--make sure the variables below are large enough for the supplied parameters
	N&#039;@propertyName nvarchar(14),@myLevel0Type nvarchar(6),@myLevel0Name nvarchar(3),@myLevel1Type nvarchar(9),@myLevel1Name nvarchar(4000),@myLevel2Type nvarchar(4000),@myLevel2Name nvarchar(4000),@propertyValue nvarchar(4000)&#039;,@propertyName=N&#039;MS_Description&#039;,
	@myLevel0Type=N&#039;SCHEMA&#039;,
	@myLevel0Name=@myschema,
	@myLevel1Type=N&#039;PROCEDURE&#039;,
	@myLevel1Name=@myproc,
	@myLevel2Type=NULL,@myLevel2Name=NULL,
	@propertyValue=@mydesc;

	-- Get the next row
	FETCH NEXT FROM metaCursor INTO @myschema,
					@myproc, @mydesc;
END			
-- Clean up
CLOSE metaCursor;
DEALLOCATE metaCursor;</description>
		<content:encoded><![CDATA[<p>Great stuff. I was looking to take comments that other developers had made in SPs and add them to the extended properties so RedGate&#8217;s SqlDoc could use them for documentation.<br />
I used your code (with a few mods due to differing comment use) then added the following code at the end to set the extended properties:</p>
<p>&#8211; Select all records in the #ProcDoc table<br />
&#8211; and replace line breaks with a space for better formatting<br />
DECLARE metaCursor CURSOR LOCAL FAST_FORWARD<br />
FOR SELECT [Schema],[Proc],REPLACE(cast([Description] as nvarchar(max)), CHAR(10), &#8216; &#8216;) FROM #ProcDoc;</p>
<p>OPEN metaCursor;<br />
FETCH NEXT FROM metaCursor INTO @myschema,<br />
				@myproc, @mydesc;</p>
<p>WHILE (@@FETCH_STATUS = 0)<br />
	BEGIN</p>
<p>		&#8211; Update MS_Description Extended property</p>
<p>	exec sp_executesql N&#8217;if (SELECT count(*)<br />
	FROM ::fn_listextendedproperty (@propertyName, @myLevel0Type, @myLevel0Name, @myLevel1Type, @myLevel1Name, @myLevel2Type, @myLevel2Name))&gt; 0<br />
	begin<br />
		EXEC sp_updateextendedproperty  @propertyName, @propertyValue, @myLevel0Type, @myLevel0Name, @myLevel1Type, @myLevel1Name, @myLevel2Type, @myLevel2Name;<br />
	end<br />
	else<br />
	begin<br />
		EXEC sp_addextendedproperty @propertyName, @propertyValue, @myLevel0Type, @myLevel0Name, @myLevel1Type, @myLevel1Name, @myLevel2Type, @myLevel2Name;<br />
	end&#8217;,<br />
	&#8211;make sure the variables below are large enough for the supplied parameters<br />
	N&#8217;@propertyName nvarchar(14),@myLevel0Type nvarchar(6),@myLevel0Name nvarchar(3),@myLevel1Type nvarchar(9),@myLevel1Name nvarchar(4000),@myLevel2Type nvarchar(4000),@myLevel2Name nvarchar(4000),@propertyValue nvarchar(4000)&#8217;,@propertyName=N&#8217;MS_Description&#8217;,<br />
	@myLevel0Type=N&#8217;SCHEMA&#8217;,<br />
	@myLevel0Name=@myschema,<br />
	@myLevel1Type=N&#8217;PROCEDURE&#8217;,<br />
	@myLevel1Name=@myproc,<br />
	@myLevel2Type=NULL,@myLevel2Name=NULL,<br />
	@propertyValue=@mydesc;</p>
<p>	&#8211; Get the next row<br />
	FETCH NEXT FROM metaCursor INTO @myschema,<br />
					@myproc, @mydesc;<br />
END<br />
&#8211; Clean up<br />
CLOSE metaCursor;<br />
DEALLOCATE metaCursor;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Weekly Link Post 129 &#171; Rhonda Tipton&#8217;s WebLog</title>
		<link>http://www.youdidwhatwithtsql.com/extract-stored-procedure-comments-with-tsql/563/comment-page-1#comment-133</link>
		<dc:creator>Weekly Link Post 129 &#171; Rhonda Tipton&#8217;s WebLog</dc:creator>
		<pubDate>Mon, 25 Jan 2010 00:27:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.youdidwhatwithtsql.com/extract-stored-procedure-comments-with-tsql/563#comment-133</guid>
		<description>[...] Extract Stored Procedure Comments with TSQL &#8211; Cool script for pulling comments out of an stored proc. [...]</description>
		<content:encoded><![CDATA[<p>[...] Extract Stored Procedure Comments with TSQL &#8211; Cool script for pulling comments out of an stored proc. [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

