<?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: SQL Puzzle: Write a Function to count the total number of word	</title>
	<atom:link href="https://www.dbrnd.com/2017/09/sql-puzzle-write-a-function-to-count-the-total-number-of-word/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com/2017/09/sql-puzzle-write-a-function-to-count-the-total-number-of-word/</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Fri, 22 Sep 2017 06:14:18 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>
	<item>
		<title>
		By: VISHNUAUTO		</title>
		<link>https://www.dbrnd.com/2017/09/sql-puzzle-write-a-function-to-count-the-total-number-of-word/#comment-5857</link>

		<dc:creator><![CDATA[VISHNUAUTO]]></dc:creator>
		<pubDate>Fri, 22 Sep 2017 06:14:18 +0000</pubDate>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6057#comment-5857</guid>

					<description><![CDATA[ALTER FUNCTION [dbo].[fn_GetWordCount] (@InputStringData VARCHAR(100)) 
RETURNS INT
AS
BEGIN
 
DECLARE @i INT
DECLARE @Char CHAR(1)
DECLARE @PrevChar CHAR(1)
DECLARE @Counter INT
 
declare @input_xml xml

select @input_xml = &#039;&#039; + replace(@InputStringData,&#039; &#039;,&#039;&#039; ) + &#039;&#039;

SELECT    @Counter=count(x.value(&#039;.&#039;,&#039;nvarchar&#039;)) 
FROM @input_xml.nodes(&#039;//*:root/*:x&#039;) y(x)
where y.x.value(&#039;.&#039;,&#039;nvarchar(100)&#039;)  &#039;&#039;
 
RETURN @Counter 
END
GO]]></description>
			<content:encoded><![CDATA[<p>ALTER FUNCTION [dbo].[fn_GetWordCount] (@InputStringData VARCHAR(100))<br />
RETURNS INT<br />
AS<br />
BEGIN</p>
<p>DECLARE @i INT<br />
DECLARE @Char CHAR(1)<br />
DECLARE @PrevChar CHAR(1)<br />
DECLARE @Counter INT</p>
<p>declare @input_xml xml</p>
<p>select @input_xml = &#8221; + replace(@InputStringData,&#8217; &#8216;,&#8221; ) + &#8221;</p>
<p>SELECT    @Counter=count(x.value(&#8216;.&#8217;,&#8217;nvarchar&#8217;))<br />
FROM @input_xml.nodes(&#8216;//*:root/*:x&#8217;) y(x)<br />
where y.x.value(&#8216;.&#8217;,&#8217;nvarchar(100)&#8217;)  &#8221;</p>
<p>RETURN @Counter<br />
END<br />
GO</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: harini		</title>
		<link>https://www.dbrnd.com/2017/09/sql-puzzle-write-a-function-to-count-the-total-number-of-word/#comment-5852</link>

		<dc:creator><![CDATA[harini]]></dc:creator>
		<pubDate>Mon, 18 Sep 2017 07:31:07 +0000</pubDate>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6057#comment-5852</guid>

					<description><![CDATA[declare @q varchar(max) = &#039;I am Database Engineer and I am the owner of dbrnd.com&#039;;
select len(@q) - len(replace(@q,&#039; &#039;,&#039;&#039;)) + 1]]></description>
			<content:encoded><![CDATA[<p>declare @q varchar(max) = &#8216;I am Database Engineer and I am the owner of dbrnd.com&#8217;;<br />
select len(@q) &#8211; len(replace(@q,&#8217; &#8216;,&#8221;)) + 1</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Anvesh Patel		</title>
		<link>https://www.dbrnd.com/2017/09/sql-puzzle-write-a-function-to-count-the-total-number-of-word/#comment-5845</link>

		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Tue, 12 Sep 2017 07:46:30 +0000</pubDate>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6057#comment-5845</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.dbrnd.com/2017/09/sql-puzzle-write-a-function-to-count-the-total-number-of-word/#comment-5844&quot;&gt;Dinesh&lt;/a&gt;.

Thank you Dinesh!]]></description>
			<content:encoded><![CDATA[<p>Thank you Dinesh!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Dinesh		</title>
		<link>https://www.dbrnd.com/2017/09/sql-puzzle-write-a-function-to-count-the-total-number-of-word/#comment-5844</link>

		<dc:creator><![CDATA[Dinesh]]></dc:creator>
		<pubDate>Tue, 12 Sep 2017 07:33:23 +0000</pubDate>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6057#comment-5844</guid>

					<description><![CDATA[--Method-1

Declare @XML As XML;
Set @XML=&#039;&#039;+Replace(&#039;I am Database Engineer and I am the owner of dbrnd.com&#039;,&#039; &#039;,&#039;&#039;)+&#039;&#039;
Select Count(r.value(&#039;.&#039;,&#039;NVarChar(Max)&#039;)) As TotalWordCount
From @XML.nodes(&#039;t&#039;) As Records(r)

GO

--Method-2

Declare @SQL NvarChar(Max)=&#039;I am Database Engineer and I am the owner of dbrnd.com&#039;
Declare @Len As Int
Declare @Cnt Int
Set @Cnt=0
While Len(@SQL)&#062;0
Begin 
			
			Set @Len=(Case CharIndex(&#039; &#039;,@SQL) When 0 Then Len(@SQL) Else CharIndex(&#039; &#039;,@SQL)-1 End)
			
			Set @Cnt=@Cnt+1
			Set @SQL=(Case Len(@SQL)-@Len When 0 Then NULL Else Right(@SQL,Len(@SQL)-@Len-1) End)
			
End
Select @Cnt	As TotalWordCount
GO]]></description>
			<content:encoded><![CDATA[<p>&#8211;Method-1</p>
<p>Declare @XML As XML;<br />
Set @XML=&#8221;+Replace(&#8216;I am Database Engineer and I am the owner of dbrnd.com&#8217;,&#8217; &#8216;,&#8221;)+&#8221;<br />
Select Count(r.value(&#8216;.&#8217;,&#8217;NVarChar(Max)&#8217;)) As TotalWordCount<br />
From @XML.nodes(&#8216;t&#8217;) As Records(r)</p>
<p>GO</p>
<p>&#8211;Method-2</p>
<p>Declare @SQL NvarChar(Max)=&#8217;I am Database Engineer and I am the owner of dbrnd.com&#8217;<br />
Declare @Len As Int<br />
Declare @Cnt Int<br />
Set @Cnt=0<br />
While Len(@SQL)&gt;0<br />
Begin </p>
<p>			Set @Len=(Case CharIndex(&#8216; &#8216;,@SQL) When 0 Then Len(@SQL) Else CharIndex(&#8216; &#8216;,@SQL)-1 End)</p>
<p>			Set @Cnt=@Cnt+1<br />
			Set @SQL=(Case Len(@SQL)-@Len When 0 Then NULL Else Right(@SQL,Len(@SQL)-@Len-1) End)</p>
<p>End<br />
Select @Cnt	As TotalWordCount<br />
GO</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
