<?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; Get Numeric Value From Alpha Numeric String &#8211; UDF for Get Numeric Numbers Only</title>
	<atom:link href="http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Mon, 13 Feb 2012 15:11:24 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: stephanie</title>
		<link>http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/#comment-223653</link>
		<dc:creator><![CDATA[stephanie]]></dc:creator>
		<pubDate>Thu, 22 Dec 2011 12:15:00 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1360#comment-223653</guid>
		<description><![CDATA[You are fantastic!!!! saved me tons of work!]]></description>
		<content:encoded><![CDATA[<p>You are fantastic!!!! saved me tons of work!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eknath</title>
		<link>http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/#comment-216748</link>
		<dc:creator><![CDATA[Eknath]]></dc:creator>
		<pubDate>Tue, 13 Dec 2011 11:36:41 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1360#comment-216748</guid>
		<description><![CDATA[Thanks a lot for your function..]]></description>
		<content:encoded><![CDATA[<p>Thanks a lot for your function..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chrissekraz</title>
		<link>http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/#comment-89217</link>
		<dc:creator><![CDATA[Chrissekraz]]></dc:creator>
		<pubDate>Fri, 24 Sep 2010 06:37:12 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1360#comment-89217</guid>
		<description><![CDATA[To handle both decimal and non-decimal numbers I&#039;ve created this procedure to handle e.g. &#039;ABC355,88ghf&#039; to 355,88 and &#039;ABC 78 QQ&#039; to 78,00 etc:

CREATE PROCEDURE [dbo].[CleanDataFromAlpha] 
	@alpha varchar(50),
	@decimal decimal(14, 5) OUTPUT
AS BEGIN
SET NOCOUNT ON;

DECLARE @ErrorMsg		varchar(50)
DECLARE @Pos			int
DECLARE @CommaPos		int
DECLARE @ZeroExists		int
DECLARE @alphaReverse	varchar(50)
DECLARE @NumPos			int
DECLARE @Len			int

	-- 1 Reverse the alpha in order to get the last position of a numeric value
	SET @alphaReverse = REVERSE(@alpha)
	-- 2 Get the last position of a numeric figure
	SET @NumPos = PATINDEX(&#039;%[0-9]%&#039;, @alphaReverse)
	-- 3 Get the lenght of the string
	SET @Len = LEN(@alpha)
	-- 4 Add a comma after the numeric data in case it&#039;s no decimal number
	SET @alpha = SUBSTRING(@alpha, 1, (@Len - @NumPos + 1)) 
				 + &#039;,&#039; 
				 + SUBSTRING(@alpha, (@Len - @NumPos + 2), 50) 
	
	-- Check if there is a zero (0) in the @alpha, then we later set the @decimal to 0
	-- if it&#039;s 0 after the handling, else we set @decimal to NULL
	-- If 0 no match, else there is a match
	SET @ZeroExists = CHARINDEX ( &#039;0&#039; , @alpha ,1 )
	
	-- Find position of , (comma)
	SET @CommaPos = 1
	SET @CommaPos = PATINDEX(&#039;%,%&#039;, @alpha)
	IF (@CommaPos = &#039;&#039;) BEGIN
		SET @CommaPos = 20
	END
		
	SET @Pos = PATINDEX(&#039;%[^0-9]%&#039;,@alpha)
	-- Replaces any aplha with &#039;0&#039; since we otherwice can&#039;t keep track of where the decimal
	-- should be put in. We assume the numeric number has no aplhe inside. The regular way
	-- to solve this is to replace with &#039;&#039;, but then we miss the way to find the place to 
	-- put in the decimal.
	WHILE (@Pos &gt; 0) BEGIN
		SET @alpha = STUFF(@alpha, @pos, 1, &#039;0&#039;)
		SET @Pos = PATINDEX(&#039;%[^0-9]%&#039;,@alpha)
	END
	
	IF (@alpha IS NOT NULL AND @alpha != &#039;&#039;) BEGIN
		SET @decimal = convert(decimal(14, 5), substring(@alpha, 1, (@CommaPos - 1)) 
					   + &#039;.&#039; 
					   + substring(@alpha, (@CommaPos + 1), 20))
	END
	-- Since we in this case don&#039;t want to set 0 if where is no numeric value, we set NULL to be safe
	IF (@decimal = 0 AND @ZeroExists = 0) BEGIN
		SET @decimal = NULL
	END
END

/ Christofer]]></description>
		<content:encoded><![CDATA[<p>To handle both decimal and non-decimal numbers I&#8217;ve created this procedure to handle e.g. &#8216;ABC355,88ghf&#8217; to 355,88 and &#8216;ABC 78 QQ&#8217; to 78,00 etc:</p>
<p>CREATE PROCEDURE [dbo].[CleanDataFromAlpha]<br />
	@alpha varchar(50),<br />
	@decimal decimal(14, 5) OUTPUT<br />
AS BEGIN<br />
SET NOCOUNT ON;</p>
<p>DECLARE @ErrorMsg		varchar(50)<br />
DECLARE @Pos			int<br />
DECLARE @CommaPos		int<br />
DECLARE @ZeroExists		int<br />
DECLARE @alphaReverse	varchar(50)<br />
DECLARE @NumPos			int<br />
DECLARE @Len			int</p>
<p>	&#8211; 1 Reverse the alpha in order to get the last position of a numeric value<br />
	SET @alphaReverse = REVERSE(@alpha)<br />
	&#8211; 2 Get the last position of a numeric figure<br />
	SET @NumPos = PATINDEX(&#8216;%[0-9]%&#8217;, @alphaReverse)<br />
	&#8211; 3 Get the lenght of the string<br />
	SET @Len = LEN(@alpha)<br />
	&#8211; 4 Add a comma after the numeric data in case it&#8217;s no decimal number<br />
	SET @alpha = SUBSTRING(@alpha, 1, (@Len &#8211; @NumPos + 1))<br />
				 + &#8216;,&#8217;<br />
				 + SUBSTRING(@alpha, (@Len &#8211; @NumPos + 2), 50) </p>
<p>	&#8211; Check if there is a zero (0) in the @alpha, then we later set the @decimal to 0<br />
	&#8211; if it&#8217;s 0 after the handling, else we set @decimal to NULL<br />
	&#8211; If 0 no match, else there is a match<br />
	SET @ZeroExists = CHARINDEX ( &#8217;0&#8242; , @alpha ,1 )</p>
<p>	&#8211; Find position of , (comma)<br />
	SET @CommaPos = 1<br />
	SET @CommaPos = PATINDEX(&#8216;%,%&#8217;, @alpha)<br />
	IF (@CommaPos = &#8221;) BEGIN<br />
		SET @CommaPos = 20<br />
	END</p>
<p>	SET @Pos = PATINDEX(&#8216;%[^0-9]%&#8217;,@alpha)<br />
	&#8211; Replaces any aplha with &#8217;0&#8242; since we otherwice can&#8217;t keep track of where the decimal<br />
	&#8211; should be put in. We assume the numeric number has no aplhe inside. The regular way<br />
	&#8211; to solve this is to replace with &#8221;, but then we miss the way to find the place to<br />
	&#8211; put in the decimal.<br />
	WHILE (@Pos &gt; 0) BEGIN<br />
		SET @alpha = STUFF(@alpha, @pos, 1, &#8217;0&#8242;)<br />
		SET @Pos = PATINDEX(&#8216;%[^0-9]%&#8217;,@alpha)<br />
	END</p>
<p>	IF (@alpha IS NOT NULL AND @alpha != &#8221;) BEGIN<br />
		SET @decimal = convert(decimal(14, 5), substring(@alpha, 1, (@CommaPos &#8211; 1))<br />
					   + &#8216;.&#8217;<br />
					   + substring(@alpha, (@CommaPos + 1), 20))<br />
	END<br />
	&#8211; Since we in this case don&#8217;t want to set 0 if where is no numeric value, we set NULL to be safe<br />
	IF (@decimal = 0 AND @ZeroExists = 0) BEGIN<br />
		SET @decimal = NULL<br />
	END<br />
END</p>
<p>/ Christofer</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sivapriya</title>
		<link>http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/#comment-77617</link>
		<dc:creator><![CDATA[Sivapriya]]></dc:creator>
		<pubDate>Fri, 25 Jun 2010 09:37:41 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1360#comment-77617</guid>
		<description><![CDATA[This really worked well,thanks]]></description>
		<content:encoded><![CDATA[<p>This really worked well,thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/#comment-61157</link>
		<dc:creator><![CDATA[Madhivanan]]></dc:creator>
		<pubDate>Mon, 15 Feb 2010 11:14:47 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1360#comment-61157</guid>
		<description><![CDATA[You can easily use split function in the application

dim sp
sp=split(string,&quot;-&quot;)

Now you can access first and second values by

sp(0) and sp(1)]]></description>
		<content:encoded><![CDATA[<p>You can easily use split function in the application</p>
<p>dim sp<br />
sp=split(string,&#8221;-&#8221;)</p>
<p>Now you can access first and second values by</p>
<p>sp(0) and sp(1)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: amit kalke</title>
		<link>http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/#comment-60727</link>
		<dc:creator><![CDATA[amit kalke]]></dc:creator>
		<pubDate>Fri, 05 Feb 2010 15:26:10 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1360#comment-60727</guid>
		<description><![CDATA[Hello sir

My senario like this , I have one text box and one table called student(Name,Roll_No) and one Insert button to insert data in DB.  If i type &quot;amit-28&quot; in textbox then by clicking on Insert button &quot;amit&quot; should inserted into Name field and &quot;28&quot; should inserted into RollNo field. So what code to write??or query ??

Thanking You]]></description>
		<content:encoded><![CDATA[<p>Hello sir</p>
<p>My senario like this , I have one text box and one table called student(Name,Roll_No) and one Insert button to insert data in DB.  If i type &#8220;amit-28&#8243; in textbox then by clicking on Insert button &#8220;amit&#8221; should inserted into Name field and &#8220;28&#8243; should inserted into RollNo field. So what code to write??or query ??</p>
<p>Thanking You</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/#comment-60715</link>
		<dc:creator><![CDATA[Madhivanan]]></dc:creator>
		<pubDate>Fri, 05 Feb 2010 13:41:15 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1360#comment-60715</guid>
		<description><![CDATA[Another method

http://beyondrelational.com/blogs/madhivanan/archive/2007/12/18/extract-only-numbers-from-a-string.aspx

Madhivanan]]></description>
		<content:encoded><![CDATA[<p>Another method</p>
<p><a href="http://beyondrelational.com/blogs/madhivanan/archive/2007/12/18/extract-only-numbers-from-a-string.aspx" rel="nofollow">http://beyondrelational.com/blogs/madhivanan/archive/2007/12/18/extract-only-numbers-from-a-string.aspx</a></p>
<p>Madhivanan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/#comment-60430</link>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
		<pubDate>Sat, 30 Jan 2010 17:32:54 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1360#comment-60430</guid>
		<description><![CDATA[Hello Andrew,

In the function dbo.udf_GetNumeric replace the line:

SET @intAlpha = PATINDEX(&#039;%[^0-9]%&#039;, @strAlphaNumeric)

with following line at two places:

SET @intAlpha = PATINDEX(&#039;%[^0-9.]%&#039;, @strAlphaNumeric)

Regards,
Pinal Dave]]></description>
		<content:encoded><![CDATA[<p>Hello Andrew,</p>
<p>In the function dbo.udf_GetNumeric replace the line:</p>
<p>SET @intAlpha = PATINDEX(&#8216;%[^0-9]%&#8217;, @strAlphaNumeric)</p>
<p>with following line at two places:</p>
<p>SET @intAlpha = PATINDEX(&#8216;%[^0-9.]%&#8217;, @strAlphaNumeric)</p>
<p>Regards,<br />
Pinal Dave</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/#comment-60410</link>
		<dc:creator><![CDATA[Andrew]]></dc:creator>
		<pubDate>Sat, 30 Jan 2010 01:52:05 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1360#comment-60410</guid>
		<description><![CDATA[How does this accomodate decimals? Like this:

&#039;Price: 3.56783&#039;

I would just want to return 3.56783]]></description>
		<content:encoded><![CDATA[<p>How does this accomodate decimals? Like this:</p>
<p>&#8216;Price: 3.56783&#8242;</p>
<p>I would just want to return 3.56783</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nizam</title>
		<link>http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/#comment-44484</link>
		<dc:creator><![CDATA[Nizam]]></dc:creator>
		<pubDate>Tue, 02 Dec 2008 10:12:24 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1360#comment-44484</guid>
		<description><![CDATA[Hi Nitin,
The above logic is giving the required result.

I think you might have missed somewhere. Please recheck it at your end.

Thanks,
Nizam]]></description>
		<content:encoded><![CDATA[<p>Hi Nitin,<br />
The above logic is giving the required result.</p>
<p>I think you might have missed somewhere. Please recheck it at your end.</p>
<p>Thanks,<br />
Nizam</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam Machanic</title>
		<link>http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/#comment-43991</link>
		<dc:creator><![CDATA[Adam Machanic]]></dc:creator>
		<pubDate>Fri, 31 Oct 2008 18:39:48 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1360#comment-43991</guid>
		<description><![CDATA[Trying again:

http://sql blog.com/blogs/adammachanic/archive/2006/07/12/patternbasedreplacementudf.aspx]]></description>
		<content:encoded><![CDATA[<p>Trying again:</p>
<p><a href="http://sql" rel="nofollow">http://sql</a> blog.com/blogs/adammachanic/archive/2006/07/12/patternbasedreplacementudf.aspx</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam Machanic</title>
		<link>http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/#comment-43973</link>
		<dc:creator><![CDATA[Adam Machanic]]></dc:creator>
		<pubDate>Thu, 30 Oct 2008 17:31:25 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1360#comment-43973</guid>
		<description><![CDATA[Nitin: I posted an alternate solution here that does what you need, but Mr. Dave has not bothered to approve the comment.]]></description>
		<content:encoded><![CDATA[<p>Nitin: I posted an alternate solution here that does what you need, but Mr. Dave has not bothered to approve the comment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nitin</title>
		<link>http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/#comment-43709</link>
		<dc:creator><![CDATA[Nitin]]></dc:creator>
		<pubDate>Wed, 15 Oct 2008 09:49:20 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1360#comment-43709</guid>
		<description><![CDATA[hi pinal.....
             with the help of this we can not remove whole alphabets in our string it removes only first group occurence of alphabets e.g. &#039;qwert12354asd34as&#039; the result of this string will be 12354asd34as as per requirment  output should be 1235434...........it need one more while loop...


nitin]]></description>
		<content:encoded><![CDATA[<p>hi pinal&#8230;..<br />
             with the help of this we can not remove whole alphabets in our string it removes only first group occurence of alphabets e.g. &#8216;qwert12354asd34as&#8217; the result of this string will be 12354asd34as as per requirment  output should be 1235434&#8230;&#8230;&#8230;..it need one more while loop&#8230;</p>
<p>nitin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: elfy</title>
		<link>http://blog.sqlauthority.com/2008/10/14/sql-server-get-numeric-value-from-alpha-numeric-string-udf-for-get-numeric-numbers-only/#comment-43695</link>
		<dc:creator><![CDATA[elfy]]></dc:creator>
		<pubDate>Tue, 14 Oct 2008 17:41:02 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1360#comment-43695</guid>
		<description><![CDATA[thanks, for me will be useful]]></description>
		<content:encoded><![CDATA[<p>thanks, for me will be useful</p>
]]></content:encoded>
	</item>
</channel>
</rss>

