<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Integration Points &#187; SQL</title>
	<atom:link href="http://dmgorman.wordpress.com/tag/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://dmgorman.wordpress.com</link>
	<description>Extending Corporate Data ...</description>
	<lastBuildDate>Wed, 16 Dec 2009 16:27:47 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='dmgorman.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/09ff9c9336e6ecd7cc49045a62d1aab3?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Integration Points &#187; SQL</title>
		<link>http://dmgorman.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://dmgorman.wordpress.com/osd.xml" title="Integration Points" />
		<item>
		<title>#07 SQL UDF to Clean Up HTML tags</title>
		<link>http://dmgorman.wordpress.com/2008/05/28/07-sql-udf-to-clean-up-html-tags/</link>
		<comments>http://dmgorman.wordpress.com/2008/05/28/07-sql-udf-to-clean-up-html-tags/#comments</comments>
		<pubDate>Wed, 28 May 2008 15:53:52 +0000</pubDate>
		<dc:creator>dmgorman</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Reporting]]></category>

		<guid isPermaLink="false">http://dmgorman.wordpress.com/?p=18</guid>
		<description><![CDATA[When using SQL Reporting to report on text fields that are formatted with html tags this user defined function UDF (a modified copy of a post by William McEvoy) is helpful. It does not clean up all but does a decent job on most common tags. You can add offending tags and code to the replace special [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dmgorman.wordpress.com&blog=2497805&post=18&subd=dmgorman&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>When using SQL Reporting to report on text fields that are formatted with html tags this user defined function UDF (a modified copy of a post by <a title="SQLMAG Link" href="http://www.sqlmag.com/Articles/ArticleID/53877/53877.html?Ad=1" target="_blank">William McEvoy</a>) is helpful. It does not clean up all but does a decent job on most common tags. You can add offending tags and code to the replace special character&#8217;s list (ie.   below)</p>
<pre class="brush: sql;">
Create FUNCTION  [dbo].[ScrapeText]
(
  @string varchar(8000)
)
returns varchar(8000)

AS
BEGIN
---------------------------------------------------------------------------------------------------
-- Title:        ScrapeText
--
-- Date Created: April 4, 2006
--
-- Author:       William McEvoy
--
-- Description:  This function will attempt to remove rtf formatting from a string. This is
--               accomplished by concetenating all text contained between greater than and less
--               than signs within the formatted text.
--
-- Example:      &lt;P&gt;This text will be parsed and returned but not the P's&lt;/P&gt;
---------------------------------------------------------------------------------------------------
-- Date Revised:  5/3/08
-- Author:       D Gorman
-- Reason:      Minor HTML tags &amp; codes added to replace
---------------------------------------------------------------------------------------------------

declare @text  varchar(8000),
        @PenDown char(1),
        @char  char(1),
        @len   int,
        @count int

select  @count = 0,
        @len   = 0,
        @text  = ''

-- Add tokens
select @string = '&gt;' + @string + '&lt;'

-- Replace Special Characters
select @string = replace(@string,'&amp;nbsp;',' ')
select @string = replace(@string,'&lt;P&gt;',char(13))
select @string = replace(@string,'&lt;/P&gt;',char(13))
select @string = replace(@string,'&amp;amp;',char(38))
select @string = replace(@string,'&amp;copy;',char(169))

-- Parse out the formatting codes
select @len = len(@string)
while (@count &lt;= @len)
begin
  select @char = substring(@string,@count,1)

  if (@char = '&gt;')
     select @PenDown = 'Y'
  else
  if (@char = '&lt;')
    select @PenDown = 'N'
  else
  if (@PenDown = 'Y')
    select @text = @text + @char

  select @count = @count + 1
end

RETURN @text
END
</pre>
<p>You would use this &#8216;upstream&#8217; on the query/view or stored procedure used by the SQL Reporting report dataset definition.  In the report def you&#8217;d just reference the NewName field reference.</p>
<p><strong>Select  dbo.ScrapeText(FieldX)  as NewName From ProjectCustomTabFields Where WBS1=&#8217;xxxxxx&#8217;</strong></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dmgorman.wordpress.com/18/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dmgorman.wordpress.com/18/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dmgorman.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dmgorman.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dmgorman.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dmgorman.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dmgorman.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dmgorman.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dmgorman.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dmgorman.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dmgorman.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dmgorman.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dmgorman.wordpress.com&blog=2497805&post=18&subd=dmgorman&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dmgorman.wordpress.com/2008/05/28/07-sql-udf-to-clean-up-html-tags/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0f40e4ba23d8f519bc9491fe6ae71f78?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dmgorman</media:title>
		</media:content>
	</item>
	</channel>
</rss>