<?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/"
	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>Comments on: SQL SERVER &#8211; Finding the Occurrence of Character in String</title>
	<atom:link href="http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 17 May 2013 15:26:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: kalindi patel</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-433368</link>
		<dc:creator><![CDATA[kalindi patel]]></dc:creator>
		<pubDate>Thu, 07 Mar 2013 11:53:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-433368</guid>
		<description><![CDATA[It is very much helpful to me and i used this site as i found perfect solution from here .]]></description>
		<content:encoded><![CDATA[<p>It is very much helpful to me and i used this site as i found perfect solution from here .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RFA</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-425129</link>
		<dc:creator><![CDATA[RFA]]></dc:creator>
		<pubDate>Thu, 21 Feb 2013 11:46:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-425129</guid>
		<description><![CDATA[Simple and clever. Thank you so much!]]></description>
		<content:encoded><![CDATA[<p>Simple and clever. Thank you so much!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Annonymous</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-408786</link>
		<dc:creator><![CDATA[Annonymous]]></dc:creator>
		<pubDate>Thu, 17 Jan 2013 04:55:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-408786</guid>
		<description><![CDATA[Here&#039;s what I did when searching in job steps for text (see Occurrences column)
	---------------------------------
	---------------------------------
	---------------------------------	
	DECLARE @SearchText VARCHAR(100)
	SET @SearchText = &#039;DBCC INPUT&#039;
	---------------------------------
	---------------------------------
	---------------------------------

	SELECT 
		job.job_id,
		job.[name],
		CASE job.enabled
			WHEN 1 THEN &#039;Yes&#039;
			ELSE &#039;No&#039;
		END AS [Is Enabled],
		jobstep.[step_name],
		(LEN(jobstep.command) - LEN(REPLACE(jobstep.command COLLATE Latin1_General_CI_AS, @SearchText, &#039;&#124;&#039;))) / LEN(@SearchText) + 1 AS [Occurrences],
		&#039;...&#039; + SUBSTRING(jobstep.command, PATINDEX(&#039;%&#039; + @SearchText + &#039;%&#039;, jobstep.command COLLATE Latin1_General_CI_AS) - 20, 50) + &#039;...&#039; AS [Found here]
	FROM
		msdb.dbo.sysjobs job
		inner join msdb.dbo.sysjobsteps jobstep on job.job_id = jobstep.job_id
	WHERE
		jobstep.command COLLATE Latin1_General_CI_AS LIKE &#039;%&#039; + @SearchText + &#039;%&#039;]]></description>
		<content:encoded><![CDATA[<p>Here&#8217;s what I did when searching in job steps for text (see Occurrences column)<br />
	&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
	&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
	&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
	DECLARE @SearchText VARCHAR(100)<br />
	SET @SearchText = &#8216;DBCC INPUT&#8217;<br />
	&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
	&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
	&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>	SELECT<br />
		job.job_id,<br />
		job.[name],<br />
		CASE job.enabled<br />
			WHEN 1 THEN &#8216;Yes&#8217;<br />
			ELSE &#8216;No&#8217;<br />
		END AS [Is Enabled],<br />
		jobstep.[step_name],<br />
		(LEN(jobstep.command) &#8211; LEN(REPLACE(jobstep.command COLLATE Latin1_General_CI_AS, @SearchText, &#8216;|&#8217;))) / LEN(@SearchText) + 1 AS [Occurrences],<br />
		&#8216;&#8230;&#8217; + SUBSTRING(jobstep.command, PATINDEX(&#8216;%&#8217; + @SearchText + &#8216;%&#8217;, jobstep.command COLLATE Latin1_General_CI_AS) &#8211; 20, 50) + &#8216;&#8230;&#8217; AS [Found here]<br />
	FROM<br />
		msdb.dbo.sysjobs job<br />
		inner join msdb.dbo.sysjobsteps jobstep on job.job_id = jobstep.job_id<br />
	WHERE<br />
		jobstep.command COLLATE Latin1_General_CI_AS LIKE &#8216;%&#8217; + @SearchText + &#8216;%&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gary Melhaff</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-392177</link>
		<dc:creator><![CDATA[Gary Melhaff]]></dc:creator>
		<pubDate>Wed, 12 Dec 2012 22:30:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-392177</guid>
		<description><![CDATA[I found method where programming isn&#039;t necessary by using the new LIKE clause variations...you can just embed it within you query and no fancy CLR callouts to regex expressions are necessary...

Here is an example of replacing any character values in a string with null...(CASE WHEN money_field LIKE &#039;%[a-zA-Z]%&#039; THEN NULL ELSE money_field END)]]></description>
		<content:encoded><![CDATA[<p>I found method where programming isn&#8217;t necessary by using the new LIKE clause variations&#8230;you can just embed it within you query and no fancy CLR callouts to regex expressions are necessary&#8230;</p>
<p>Here is an example of replacing any character values in a string with null&#8230;(CASE WHEN money_field LIKE &#8216;%[a-zA-Z]%&#8217; THEN NULL ELSE money_field END)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kunal</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-382370</link>
		<dc:creator><![CDATA[kunal]]></dc:creator>
		<pubDate>Wed, 28 Nov 2012 05:57:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-382370</guid>
		<description><![CDATA[Here is i/p of a table:
Name Surname unique id
kunal  &amp; Raj Anand 1
Ram &amp; k kelly &amp; R Singh 2
Rahan &amp; raj &amp; kali kumar 3

How to get o/p like this:--

Name Surname unique id
kunal anand 1
Raj Anand 1
Ram Singh 2
k kelly Singh 2
R Singh 2
Rahan kumar 3
raj kumar 3
kali kumar 3]]></description>
		<content:encoded><![CDATA[<p>Here is i/p of a table:<br />
Name Surname unique id<br />
kunal  &amp; Raj Anand 1<br />
Ram &amp; k kelly &amp; R Singh 2<br />
Rahan &amp; raj &amp; kali kumar 3</p>
<p>How to get o/p like this:&#8211;</p>
<p>Name Surname unique id<br />
kunal anand 1<br />
Raj Anand 1<br />
Ram Singh 2<br />
k kelly Singh 2<br />
R Singh 2<br />
Rahan kumar 3<br />
raj kumar 3<br />
kali kumar 3</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pgfiore</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-381396</link>
		<dc:creator><![CDATA[pgfiore]]></dc:creator>
		<pubDate>Mon, 26 Nov 2012 15:43:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-381396</guid>
		<description><![CDATA[Yanick do you mean SELECT LEN(REPLACE(@test,’string&#039;,’string+1char’) )– LEN(@test)?]]></description>
		<content:encoded><![CDATA[<p>Yanick do you mean SELECT LEN(REPLACE(@test,’string&#8217;,’string+1char’) )– LEN(@test)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Suvendu</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-369498</link>
		<dc:creator><![CDATA[Suvendu]]></dc:creator>
		<pubDate>Mon, 05 Nov 2012 07:48:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-369498</guid>
		<description><![CDATA[Intelligent way, Sir :)]]></description>
		<content:encoded><![CDATA[<p>Intelligent way, Sir :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yanick</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-366202</link>
		<dc:creator><![CDATA[Yanick]]></dc:creator>
		<pubDate>Mon, 29 Oct 2012 15:52:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-366202</guid>
		<description><![CDATA[A simple and efficient way to count the occurrences in a string:
Here we are counting the number of As
DECLARE @test VARCHAR(150)
SET @test = &#039;aaaaabbbbb&#039;

SELECT REPLACE(@test,&#039;a&#039;,&#039;aa&#039;) - LEN(@test)]]></description>
		<content:encoded><![CDATA[<p>A simple and efficient way to count the occurrences in a string:<br />
Here we are counting the number of As<br />
DECLARE @test VARCHAR(150)<br />
SET @test = &#8216;aaaaabbbbb&#8217;</p>
<p>SELECT REPLACE(@test,&#8217;a',&#8217;aa&#8217;) &#8211; LEN(@test)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mukhtar</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-359171</link>
		<dc:creator><![CDATA[mukhtar]]></dc:creator>
		<pubDate>Fri, 12 Oct 2012 13:20:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-359171</guid>
		<description><![CDATA[i want to create a slang filter function.

want a query which returns no of slang in a string (select query).

i.e. 
Table : Slans
slangs
-----------------
aa
bb
cc
dd
ee

result required.
===================
string                 slang_cnt              slangs
====================================================
aa cc bsf kk ff ee     3                     aa, cc, ee]]></description>
		<content:encoded><![CDATA[<p>i want to create a slang filter function.</p>
<p>want a query which returns no of slang in a string (select query).</p>
<p>i.e.<br />
Table : Slans<br />
slangs<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
aa<br />
bb<br />
cc<br />
dd<br />
ee</p>
<p>result required.<br />
===================<br />
string                 slang_cnt              slangs<br />
====================================================<br />
aa cc bsf kk ff ee     3                     aa, cc, ee</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony Bromirski</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-341558</link>
		<dc:creator><![CDATA[Tony Bromirski]]></dc:creator>
		<pubDate>Thu, 06 Sep 2012 17:13:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-341558</guid>
		<description><![CDATA[Thought I would share this handy (but simple) function for finding the Nth occurrence of a character in a string.

REF: http://www.sqlservercentral.com/scripts/Miscellaneous/30497/

Also, an example of how I used it...

--String value
--tblData.UserLogString = &#039;John.Doe,4,Johnathan,Doe,Johnathan.Doe@domain.com,True,False&#124;&#039;

--Extract the UserID from string value.
SUBSTRING( tblData.UserLogString, 0, CHARINDEX( &#039;,&#039;, tblData.UserLogString, 0 ) )
Value returned: &quot;John.Doe&quot;

--Extract the User Name (First Last) from string value.
REPLACE( 
	SUBSTRING( tblData.UserLogString, CHARINDEX2( &#039;,&#039;, tblData.UserLogString, 2 ) + 1, ( CHARINDEX2( &#039;,&#039;, tblData.UserLogString, 4 ) - CHARINDEX2( &#039;,&#039;, tblData.UserLogString, 2 ) ) - 1 ),
	&#039;,&#039; , 
	&#039; &#039; )
Value returned: &quot;Johnathan Doe&quot;

--Extract the email ID from string value.
SUBSTRING(tblData.UserLogString, 
	CHARINDEX2( &#039;,&#039;, tblData.UserLogString, 4 ) + 1 , 
	( CHARINDEX2( &#039;,&#039;, tblData.UserLogString, 5 ) - 
		CHARINDEX2( &#039;,&#039;, tblData.UserLogString, 4 ) ) - 1 ),
Value returned: &quot;Johnathan.Doe@domain.com&quot;

I&#039;m sure this can be done many other ways... Also I disagreed with the author in how I created the SPROC - I created it with the command:
CREATE FUNCTION [dbo].[CharIndex2]

Cheers, 

(p.s. Pinal - I enjoy your column!)]]></description>
		<content:encoded><![CDATA[<p>Thought I would share this handy (but simple) function for finding the Nth occurrence of a character in a string.</p>
<p>REF: <a href="http://www.sqlservercentral.com/scripts/Miscellaneous/30497/" rel="nofollow">http://www.sqlservercentral.com/scripts/Miscellaneous/30497/</a></p>
<p>Also, an example of how I used it&#8230;</p>
<p>&#8211;String value<br />
&#8211;tblData.UserLogString = &#8216;John.Doe,4,Johnathan,Doe,Johnathan.Doe@domain.com,True,False|&#8217;</p>
<p>&#8211;Extract the UserID from string value.<br />
SUBSTRING( tblData.UserLogString, 0, CHARINDEX( &#8216;,&#8217;, tblData.UserLogString, 0 ) )<br />
Value returned: &#8220;John.Doe&#8221;</p>
<p>&#8211;Extract the User Name (First Last) from string value.<br />
REPLACE(<br />
	SUBSTRING( tblData.UserLogString, CHARINDEX2( &#8216;,&#8217;, tblData.UserLogString, 2 ) + 1, ( CHARINDEX2( &#8216;,&#8217;, tblData.UserLogString, 4 ) &#8211; CHARINDEX2( &#8216;,&#8217;, tblData.UserLogString, 2 ) ) &#8211; 1 ),<br />
	&#8216;,&#8217; ,<br />
	&#8216; &#8216; )<br />
Value returned: &#8220;Johnathan Doe&#8221;</p>
<p>&#8211;Extract the email ID from string value.<br />
SUBSTRING(tblData.UserLogString,<br />
	CHARINDEX2( &#8216;,&#8217;, tblData.UserLogString, 4 ) + 1 ,<br />
	( CHARINDEX2( &#8216;,&#8217;, tblData.UserLogString, 5 ) &#8211;<br />
		CHARINDEX2( &#8216;,&#8217;, tblData.UserLogString, 4 ) ) &#8211; 1 ),<br />
Value returned: &#8220;Johnathan.Doe@domain.com&#8221;</p>
<p>I&#8217;m sure this can be done many other ways&#8230; Also I disagreed with the author in how I created the SPROC &#8211; I created it with the command:<br />
CREATE FUNCTION [dbo].[CharIndex2]</p>
<p>Cheers, </p>
<p>(p.s. Pinal &#8211; I enjoy your column!)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Velu</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-321842</link>
		<dc:creator><![CDATA[Velu]]></dc:creator>
		<pubDate>Mon, 30 Jul 2012 13:22:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-321842</guid>
		<description><![CDATA[thanks for u r cmnt....]]></description>
		<content:encoded><![CDATA[<p>thanks for u r cmnt&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aarti</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-320297</link>
		<dc:creator><![CDATA[Aarti]]></dc:creator>
		<pubDate>Sat, 28 Jul 2012 12:46:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-320297</guid>
		<description><![CDATA[can u plz tell how to fing a name which contains only 2 time &quot;a&quot;]]></description>
		<content:encoded><![CDATA[<p>can u plz tell how to fing a name which contains only 2 time &#8220;a&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ONjefu</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-295093</link>
		<dc:creator><![CDATA[ONjefu]]></dc:creator>
		<pubDate>Wed, 06 Jun 2012 06:27:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-295093</guid>
		<description><![CDATA[Very handy. Thank you!]]></description>
		<content:encoded><![CDATA[<p>Very handy. Thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sahhnawaz</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-259971</link>
		<dc:creator><![CDATA[Sahhnawaz]]></dc:creator>
		<pubDate>Tue, 06 Mar 2012 08:21:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-259971</guid>
		<description><![CDATA[Hello Pinal,
It is very interesting example, and your example is marvelous..
salute to you]]></description>
		<content:encoded><![CDATA[<p>Hello Pinal,<br />
It is very interesting example, and your example is marvelous..<br />
salute to you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ashish</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-201172</link>
		<dc:creator><![CDATA[ashish]]></dc:creator>
		<pubDate>Mon, 21 Nov 2011 10:59:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-201172</guid>
		<description><![CDATA[Dear Pinal Sir,
     
                          Thanks a lot, your nots are always very helpful to me.]]></description>
		<content:encoded><![CDATA[<p>Dear Pinal Sir,</p>
<p>                          Thanks a lot, your nots are always very helpful to me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sushant Dalvi</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-156158</link>
		<dc:creator><![CDATA[Sushant Dalvi]]></dc:creator>
		<pubDate>Thu, 11 Aug 2011 11:49:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-156158</guid>
		<description><![CDATA[above table

Cityname	operatorname	        prefix
Kolkata	Unitech Wireless	90620-90629 82960-82969
Kolkata	Datacom Solutions	90730-90739
Kolkata	BSNL	                94330-94339 94320-94325 94770-94779             
Kolkata	Loop	                 91100-91109
Kolkata	Reliance Telecom	98830-98839 96810-96819 88200-88209
Mumbai	BPL Mobile	        98210-98219 96640-96649 97730-97739 
Mumbai	Bharti Airtel	        98670-98679 98920-98929 99670-99674 

Wanted output like mentione in below table

Cityname	operatorname	      prefix
Kolkata	Unitech Wireless	90620
Kolkata	Unitech Wireless	90621
Kolkata	Unitech Wireless	90622
Kolkata	Unitech Wireless	90623
Kolkata	Unitech Wireless	90624
Kolkata	Unitech Wireless	90625
Kolkata	Unitech Wireless	90626
Kolkata	Unitech Wireless	90627
Kolkata	Unitech Wireless	90628
Kolkata	Unitech Wireless	90629
Kolkata	Unitech Wireless	82960
…..		
…..		
…..		
Kolkata	Unitech Wireless	82969
Kolkata	Datacom Solutions	90730
Kolkata	Datacom Solutions	90731
So on…..		


pls suggest]]></description>
		<content:encoded><![CDATA[<p>above table</p>
<p>Cityname	operatorname	        prefix<br />
Kolkata	Unitech Wireless	90620-90629 82960-82969<br />
Kolkata	Datacom Solutions	90730-90739<br />
Kolkata	BSNL	                94330-94339 94320-94325 94770-94779<br />
Kolkata	Loop	                 91100-91109<br />
Kolkata	Reliance Telecom	98830-98839 96810-96819 88200-88209<br />
Mumbai	BPL Mobile	        98210-98219 96640-96649 97730-97739<br />
Mumbai	Bharti Airtel	        98670-98679 98920-98929 99670-99674 </p>
<p>Wanted output like mentione in below table</p>
<p>Cityname	operatorname	      prefix<br />
Kolkata	Unitech Wireless	90620<br />
Kolkata	Unitech Wireless	90621<br />
Kolkata	Unitech Wireless	90622<br />
Kolkata	Unitech Wireless	90623<br />
Kolkata	Unitech Wireless	90624<br />
Kolkata	Unitech Wireless	90625<br />
Kolkata	Unitech Wireless	90626<br />
Kolkata	Unitech Wireless	90627<br />
Kolkata	Unitech Wireless	90628<br />
Kolkata	Unitech Wireless	90629<br />
Kolkata	Unitech Wireless	82960<br />
…..<br />
…..<br />
…..<br />
Kolkata	Unitech Wireless	82969<br />
Kolkata	Datacom Solutions	90730<br />
Kolkata	Datacom Solutions	90731<br />
So on…..		</p>
<p>pls suggest</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ajit Pratap</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-136559</link>
		<dc:creator><![CDATA[Ajit Pratap]]></dc:creator>
		<pubDate>Wed, 25 May 2011 08:58:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-136559</guid>
		<description><![CDATA[good

thanks  a lot

Regards

Ajit]]></description>
		<content:encoded><![CDATA[<p>good</p>
<p>thanks  a lot</p>
<p>Regards</p>
<p>Ajit</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hien Le</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-120165</link>
		<dc:creator><![CDATA[Hien Le]]></dc:creator>
		<pubDate>Wed, 23 Feb 2011 00:31:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-120165</guid>
		<description><![CDATA[Hi Pinal,

Great stuff, but in regards to this comment of yours - 

&quot;... Additionally, make sure that your strings does not have leading or trailing empty spaces. If you have it, you may want to use LTRIM or RTRIM functions.&quot;

Is there a reason for not using DATALENGTH instead of LEN? 

With the use of DATALENGTH you won&#039;t have to LTRIM and RTRIM. Plus you can also search for space(s) as well. 

I have only carried out limit testing and have not done any searching for issue(s) with DATALENGTH. 

DECLARE 
	@varString VARCHAR(4000),
	@varCharPattern1 VARCHAR(20),
	@varCharPattern2 VARCHAR(20),
	@varCharPattern3 VARCHAR(20)

SET @varString = &#039; Some random  text aslkja  aslkwe ld axls &#039;
SET @varCharPattern1 = &#039;  &#039;
SET @varCharPattern2 = &#039;as&#039;
SET @varCharPattern3 = &#039; &#039;

SELECT (DATALENGTH(@varString) - DATALENGTH(REPLACE(@varString, @varCharPattern1, &#039;&#039;)))/DATALENGTH(@varCharPattern1)
SELECT (DATALENGTH(@varString) - DATALENGTH(REPLACE(@varString, @varCharPattern2, &#039;&#039;)))/DATALENGTH(@varCharPattern2)
SELECT (DATALENGTH(@varString) - DATALENGTH(REPLACE(@varString, @varCharPattern3, &#039;&#039;)))/DATALENGTH(@varCharPattern3)



Thanks,

Hien]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>Great stuff, but in regards to this comment of yours &#8211; </p>
<p>&#8220;&#8230; Additionally, make sure that your strings does not have leading or trailing empty spaces. If you have it, you may want to use LTRIM or RTRIM functions.&#8221;</p>
<p>Is there a reason for not using DATALENGTH instead of LEN? </p>
<p>With the use of DATALENGTH you won&#8217;t have to LTRIM and RTRIM. Plus you can also search for space(s) as well. </p>
<p>I have only carried out limit testing and have not done any searching for issue(s) with DATALENGTH. </p>
<p>DECLARE<br />
	@varString VARCHAR(4000),<br />
	@varCharPattern1 VARCHAR(20),<br />
	@varCharPattern2 VARCHAR(20),<br />
	@varCharPattern3 VARCHAR(20)</p>
<p>SET @varString = &#8216; Some random  text aslkja  aslkwe ld axls &#8216;<br />
SET @varCharPattern1 = &#8216;  &#8216;<br />
SET @varCharPattern2 = &#8216;as&#8217;<br />
SET @varCharPattern3 = &#8216; &#8216;</p>
<p>SELECT (DATALENGTH(@varString) &#8211; DATALENGTH(REPLACE(@varString, @varCharPattern1, &#8221;)))/DATALENGTH(@varCharPattern1)<br />
SELECT (DATALENGTH(@varString) &#8211; DATALENGTH(REPLACE(@varString, @varCharPattern2, &#8221;)))/DATALENGTH(@varCharPattern2)<br />
SELECT (DATALENGTH(@varString) &#8211; DATALENGTH(REPLACE(@varString, @varCharPattern3, &#8221;)))/DATALENGTH(@varCharPattern3)</p>
<p>Thanks,</p>
<p>Hien</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hamid</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-90649</link>
		<dc:creator><![CDATA[Hamid]]></dc:creator>
		<pubDate>Sat, 02 Oct 2010 11:50:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-90649</guid>
		<description><![CDATA[ALTER FUNCTION [dbo].[CountWord]
(
	-- Add the parameters for the function here
	@RowStr nvarchar(1000),
	@WordStr nvarchar(255)
)
RETURNS   int
AS
BEGIN
	
	declare @WordCount int
	declare @index int 

	set @index =0
	set @WordCount  = 0

while CHARINDEX(@WordStr, @RowStr,@index)&gt;0
begin

	SET @index =  CHARINDEX(@WordStr,@RowStr,@index)
	SET @WordCount = @WordCount  + 1
	if @index =0
	break
	else
	SET @index = @index + 1 
end

	RETURN @WordCount 

END]]></description>
		<content:encoded><![CDATA[<p>ALTER FUNCTION [dbo].[CountWord]<br />
(<br />
	&#8211; Add the parameters for the function here<br />
	@RowStr nvarchar(1000),<br />
	@WordStr nvarchar(255)<br />
)<br />
RETURNS   int<br />
AS<br />
BEGIN</p>
<p>	declare @WordCount int<br />
	declare @index int </p>
<p>	set @index =0<br />
	set @WordCount  = 0</p>
<p>while CHARINDEX(@WordStr, @RowStr,@index)&gt;0<br />
begin</p>
<p>	SET @index =  CHARINDEX(@WordStr,@RowStr,@index)<br />
	SET @WordCount = @WordCount  + 1<br />
	if @index =0<br />
	break<br />
	else<br />
	SET @index = @index + 1<br />
end</p>
<p>	RETURN @WordCount </p>
<p>END</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shashi Sekhar</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-89571</link>
		<dc:creator><![CDATA[Shashi Sekhar]]></dc:creator>
		<pubDate>Sun, 26 Sep 2010 17:48:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-89571</guid>
		<description><![CDATA[Sir,
   I am studing your blog. It is very good for everyone who wants to learn SQL.
             Here in your blog based on Finding the occurrence of character in a string you gave two example. One is for caracter and other for word. Here i want to tell you that in the first example there is some problem. When i run the example i found that the result is different while in your case the result are same.  

CntReplaceChars      CntOccurrenceChars.
      8                                 2]]></description>
		<content:encoded><![CDATA[<p>Sir,<br />
   I am studing your blog. It is very good for everyone who wants to learn SQL.<br />
             Here in your blog based on Finding the occurrence of character in a string you gave two example. One is for caracter and other for word. Here i want to tell you that in the first example there is some problem. When i run the example i found that the result is different while in your case the result are same.  </p>
<p>CntReplaceChars      CntOccurrenceChars.<br />
      8                                 2</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jagan</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-85250</link>
		<dc:creator><![CDATA[Jagan]]></dc:creator>
		<pubDate>Wed, 25 Aug 2010 15:55:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-85250</guid>
		<description><![CDATA[Hi Pinal,

               Thanks for the SQL.  I love your articles.  Very good.  Continue this effort.

Take care,
Jagan.]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>               Thanks for the SQL.  I love your articles.  Very good.  Continue this effort.</p>
<p>Take care,<br />
Jagan.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Animesh Upadhyay</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-84761</link>
		<dc:creator><![CDATA[Animesh Upadhyay]]></dc:creator>
		<pubDate>Fri, 20 Aug 2010 22:43:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-84761</guid>
		<description><![CDATA[Hi Pinal,

I am a regular reader of your blog, kindly accept my heartfelt thanks for sharing your wisdom. Thanks again for the great post and the t-sql examples. It seems there is a typo error in the output for the first example, it should be:

CntReplacedChars     CntOccuranceChars
--------------------         --------------------
8                                2

Just to avoid any doubt for the readers.

Thanks &amp; Regards,
Animesh]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>I am a regular reader of your blog, kindly accept my heartfelt thanks for sharing your wisdom. Thanks again for the great post and the t-sql examples. It seems there is a typo error in the output for the first example, it should be:</p>
<p>CntReplacedChars     CntOccuranceChars<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;         &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
8                                2</p>
<p>Just to avoid any doubt for the readers.</p>
<p>Thanks &amp; Regards,<br />
Animesh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: amigasger</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-84338</link>
		<dc:creator><![CDATA[amigasger]]></dc:creator>
		<pubDate>Mon, 16 Aug 2010 22:51:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-84338</guid>
		<description><![CDATA[Thanks again, Pinal.
I really love these T-SQL-examples. Especially string-manipulation is hard in T-SQL compared to other languages, so thumbs up for sharing your knowledge.]]></description>
		<content:encoded><![CDATA[<p>Thanks again, Pinal.<br />
I really love these T-SQL-examples. Especially string-manipulation is hard in T-SQL compared to other languages, so thumbs up for sharing your knowledge.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ramdas</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-84299</link>
		<dc:creator><![CDATA[Ramdas]]></dc:creator>
		<pubDate>Mon, 16 Aug 2010 13:34:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-84299</guid>
		<description><![CDATA[Cool example. 
Hi Fairoze,
LEN - Returns the lenght of the string.
REPLACE - allows one to replace characters in a given string.
Check out books online for more examples and detailed explanation.]]></description>
		<content:encoded><![CDATA[<p>Cool example.<br />
Hi Fairoze,<br />
LEN &#8211; Returns the lenght of the string.<br />
REPLACE &#8211; allows one to replace characters in a given string.<br />
Check out books online for more examples and detailed explanation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tobi</title>
		<link>http://blog.sqlauthority.com/2010/08/16/sql-server-finding-the-occurrence-of-character-in-string/#comment-84273</link>
		<dc:creator><![CDATA[tobi]]></dc:creator>
		<pubDate>Mon, 16 Aug 2010 10:14:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=9907#comment-84273</guid>
		<description><![CDATA[I am sorry for all of you who have to do string manipulation in SQL during their day jobs because they are stuck in a legacy codebase.]]></description>
		<content:encoded><![CDATA[<p>I am sorry for all of you who have to do string manipulation in SQL during their day jobs because they are stuck in a legacy codebase.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
