<?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; UDF &#8211; User Defined Function to Extract Only Numbers From String</title>
	<atom:link href="http://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/</link>
	<description>Notes of a SQL Server MVP and Database Administrator</description>
	<lastBuildDate>Sat, 21 Nov 2009 05:54:09 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Stefan</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/#comment-56114</link>
		<dc:creator>Stefan</dc:creator>
		<pubDate>Thu, 24 Sep 2009 07:25:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-user-defined-function-to-extract-only-numbers-from-string/#comment-56114</guid>
		<description>Thanks a lot. Very helpful.</description>
		<content:encoded><![CDATA[<p>Thanks a lot. Very helpful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adam</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/#comment-54275</link>
		<dc:creator>adam</dc:creator>
		<pubDate>Thu, 30 Jul 2009 16:35:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-user-defined-function-to-extract-only-numbers-from-string/#comment-54275</guid>
		<description>how can i get all numeric values as a table ?

i mean, the result should be in a table like that..

Number
3
323
111

not scalar varchar value...

Thanks</description>
		<content:encoded><![CDATA[<p>how can i get all numeric values as a table ?</p>
<p>i mean, the result should be in a table like that..</p>
<p>Number<br />
3<br />
323<br />
111</p>
<p>not scalar varchar value&#8230;</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/#comment-52857</link>
		<dc:creator>pinaldave</dc:creator>
		<pubDate>Tue, 09 Jun 2009 03:39:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-user-defined-function-to-extract-only-numbers-from-string/#comment-52857</guid>
		<description>This comment is sent to me in email by our SQL Expert Imran Mohammed.

Reply to Asif, 

@Asif

CREATE FUNCTION [dbo].[UFN_Eliminate_Alphabet] (@string varchar(max))
RETURNS int 
AS
BEGIN 
	DECLARE @result varchar(50)
	DECLARE @position int
		SET @position = 1
		SET @result = &#039;&#039;

	WHILE @position &lt;= DATALENGTH(@string)
	   BEGIN
			SELECT @result = @result +	case	when (ASCII(SUBSTRING(@string, @position, 1))) between 48 and 57 then SUBSTRING(@string, @position, 1)
												else &#039;&#039;
										end 
			SET @position = @position + 1
	   END
		RETURN ( select convert ( int, @result))
END 
GO 
-- Sample to Execute 
select [dbo].[UFN_Eliminate_Alphabet](&#039;abc64h5n5u&#039;)
GO
CREATE FUNCTION [dbo].[UFN_Eliminate_Numbers] (@string varchar(max))
RETURNS varchar  (max)
AS
BEGIN
	DECLARE @result varchar(50)
	DECLARE @position int
		SET @position = 1
		Set @result = &#039;&#039;
	WHILE @position &lt;= DATALENGTH(@string)
		BEGIN
			SELECT @result = @result +	case	when	ASCII(SUBSTRING(@string, @position, 1)) between 97 and 122 then SUBSTRING(@string, @position, 1)
												when	ASCII(SUBSTRING(@string, @position, 1)) between 65 and 90 then SUBSTRING(@string, @position, 1)
												else	&#039;&#039;
										end 
			SET @position = @position + 1
		END
	RETURN	( select @result As ID 	)
END
GO 
-- Sample to Execute 
select [dbo].[UFN_Eliminate_Numbers](&#039;abc64h5n5u&#039;)
GO</description>
		<content:encoded><![CDATA[<p>This comment is sent to me in email by our SQL Expert Imran Mohammed.</p>
<p>Reply to Asif, </p>
<p>@Asif</p>
<p>CREATE FUNCTION [dbo].[UFN_Eliminate_Alphabet] (@string varchar(max))<br />
RETURNS int<br />
AS<br />
BEGIN<br />
	DECLARE @result varchar(50)<br />
	DECLARE @position int<br />
		SET @position = 1<br />
		SET @result = &#8221;</p>
<p>	WHILE @position &lt;= DATALENGTH(@string)<br />
	   BEGIN<br />
			SELECT @result = @result +	case	when (ASCII(SUBSTRING(@string, @position, 1))) between 48 and 57 then SUBSTRING(@string, @position, 1)<br />
												else &#039;&#039;<br />
										end<br />
			SET @position = @position + 1<br />
	   END<br />
		RETURN ( select convert ( int, @result))<br />
END<br />
GO<br />
&#8211; Sample to Execute<br />
select [dbo].[UFN_Eliminate_Alphabet](&#039;abc64h5n5u&#039;)<br />
GO<br />
CREATE FUNCTION [dbo].[UFN_Eliminate_Numbers] (@string varchar(max))<br />
RETURNS varchar  (max)<br />
AS<br />
BEGIN<br />
	DECLARE @result varchar(50)<br />
	DECLARE @position int<br />
		SET @position = 1<br />
		Set @result = &#039;&#039;<br />
	WHILE @position &lt;= DATALENGTH(@string)<br />
		BEGIN<br />
			SELECT @result = @result +	case	when	ASCII(SUBSTRING(@string, @position, 1)) between 97 and 122 then SUBSTRING(@string, @position, 1)<br />
												when	ASCII(SUBSTRING(@string, @position, 1)) between 65 and 90 then SUBSTRING(@string, @position, 1)<br />
												else	&#039;&#039;<br />
										end<br />
			SET @position = @position + 1<br />
		END<br />
	RETURN	( select @result As ID 	)<br />
END<br />
GO<br />
&#8211; Sample to Execute<br />
select [dbo].[UFN_Eliminate_Numbers](&#039;abc64h5n5u&#039;)<br />
GO</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/#comment-52856</link>
		<dc:creator>Imran Mohammed</dc:creator>
		<pubDate>Tue, 09 Jun 2009 03:34:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-user-defined-function-to-extract-only-numbers-from-string/#comment-52856</guid>
		<description>Reply to Asif, 

First function 

CREATE FUNCTION [dbo].[UFN_Eliminate_Alphabet] (@string varchar(max))
RETURNS int 
AS
BEGIN 
	DECLARE @result varchar(50)
	DECLARE @position int
		SET @position = 1
		SET @result = &#039;&#039;

	WHILE @position &lt;= DATALENGTH(@string)
	   BEGIN
			SELECT @result = @result +	case	when (ASCII(SUBSTRING(@string, @position, 1))) between 48 and 57 then SUBSTRING(@string, @position, 1)
												else &#039;&#039;
										end 
			SET @position = @position + 1
	   END
		RETURN ( select convert ( int, @result))
END 
GO 
-- Sample to Execute 
select [dbo].[UFN_Eliminate_Alphabet](&#039;abc64h5n5u&#039;)

~IM</description>
		<content:encoded><![CDATA[<p>Reply to Asif, </p>
<p>First function </p>
<p>CREATE FUNCTION [dbo].[UFN_Eliminate_Alphabet] (@string varchar(max))<br />
RETURNS int<br />
AS<br />
BEGIN<br />
	DECLARE @result varchar(50)<br />
	DECLARE @position int<br />
		SET @position = 1<br />
		SET @result = &#8221;</p>
<p>	WHILE @position &lt;= DATALENGTH(@string)<br />
	   BEGIN<br />
			SELECT @result = @result +	case	when (ASCII(SUBSTRING(@string, @position, 1))) between 48 and 57 then SUBSTRING(@string, @position, 1)<br />
												else &#039;&#039;<br />
										end<br />
			SET @position = @position + 1<br />
	   END<br />
		RETURN ( select convert ( int, @result))<br />
END<br />
GO<br />
&#8211; Sample to Execute<br />
select [dbo].[UFN_Eliminate_Alphabet](&#039;abc64h5n5u&#039;)</p>
<p>~IM</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/#comment-52855</link>
		<dc:creator>Imran Mohammed</dc:creator>
		<pubDate>Tue, 09 Jun 2009 03:33:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-user-defined-function-to-extract-only-numbers-from-string/#comment-52855</guid>
		<description>Reply to Asif, 

@Asif

CREATE FUNCTION [dbo].[UFN_Eliminate_Alphabet] (@string varchar(max))
RETURNS int 
AS
BEGIN 
	DECLARE @result varchar(50)
	DECLARE @position int
		SET @position = 1
		SET @result = &#039;&#039;

	WHILE @position &lt;= DATALENGTH(@string)
	   BEGIN
			SELECT @result = @result +	case	when (ASCII(SUBSTRING(@string, @position, 1))) between 48 and 57 then SUBSTRING(@string, @position, 1)
												else &#039;&#039;
										end 
			SET @position = @position + 1
	   END
		RETURN ( select convert ( int, @result))
END 
GO 
-- Sample to Execute 
select [dbo].[UFN_Eliminate_Alphabet](&#039;abc64h5n5u&#039;)
GO
CREATE FUNCTION [dbo].[UFN_Eliminate_Numbers] (@string varchar(max))
RETURNS varchar  (max)
AS
BEGIN
	DECLARE @result varchar(50)
	DECLARE @position int
		SET @position = 1
		Set @result = &#039;&#039;
	WHILE @position &lt;= DATALENGTH(@string)
		BEGIN
			SELECT @result = @result +	case	when	ASCII(SUBSTRING(@string, @position, 1)) between 97 and 122 then SUBSTRING(@string, @position, 1)
												when	ASCII(SUBSTRING(@string, @position, 1)) between 65 and 90 then SUBSTRING(@string, @position, 1)
												else	&#039;&#039;
										end 
			SET @position = @position + 1
		END
	RETURN	( select @result As ID 	)
END
GO 
-- Sample to Execute 
select [dbo].[UFN_Eliminate_Numbers](&#039;abc64h5n5u&#039;)
GO</description>
		<content:encoded><![CDATA[<p>Reply to Asif, </p>
<p>@Asif</p>
<p>CREATE FUNCTION [dbo].[UFN_Eliminate_Alphabet] (@string varchar(max))<br />
RETURNS int<br />
AS<br />
BEGIN<br />
	DECLARE @result varchar(50)<br />
	DECLARE @position int<br />
		SET @position = 1<br />
		SET @result = &#8221;</p>
<p>	WHILE @position &lt;= DATALENGTH(@string)<br />
	   BEGIN<br />
			SELECT @result = @result +	case	when (ASCII(SUBSTRING(@string, @position, 1))) between 48 and 57 then SUBSTRING(@string, @position, 1)<br />
												else &#039;&#039;<br />
										end<br />
			SET @position = @position + 1<br />
	   END<br />
		RETURN ( select convert ( int, @result))<br />
END<br />
GO<br />
&#8211; Sample to Execute<br />
select [dbo].[UFN_Eliminate_Alphabet](&#039;abc64h5n5u&#039;)<br />
GO<br />
CREATE FUNCTION [dbo].[UFN_Eliminate_Numbers] (@string varchar(max))<br />
RETURNS varchar  (max)<br />
AS<br />
BEGIN<br />
	DECLARE @result varchar(50)<br />
	DECLARE @position int<br />
		SET @position = 1<br />
		Set @result = &#039;&#039;<br />
	WHILE @position &lt;= DATALENGTH(@string)<br />
		BEGIN<br />
			SELECT @result = @result +	case	when	ASCII(SUBSTRING(@string, @position, 1)) between 97 and 122 then SUBSTRING(@string, @position, 1)<br />
												when	ASCII(SUBSTRING(@string, @position, 1)) between 65 and 90 then SUBSTRING(@string, @position, 1)<br />
												else	&#039;&#039;<br />
										end<br />
			SET @position = @position + 1<br />
		END<br />
	RETURN	( select @result As ID 	)<br />
END<br />
GO<br />
&#8211; Sample to Execute<br />
select [dbo].[UFN_Eliminate_Numbers](&#039;abc64h5n5u&#039;)<br />
GO</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Tkatch</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/#comment-52838</link>
		<dc:creator>Brian Tkatch</dc:creator>
		<pubDate>Mon, 08 Jun 2009 17:00:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-user-defined-function-to-extract-only-numbers-from-string/#comment-52838</guid>
		<description>@asif

Please provide sample output.</description>
		<content:encoded><![CDATA[<p>@asif</p>
<p>Please provide sample output.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: asif</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/#comment-52835</link>
		<dc:creator>asif</dc:creator>
		<pubDate>Mon, 08 Jun 2009 16:01:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-user-defined-function-to-extract-only-numbers-from-string/#comment-52835</guid>
		<description>plz help me i have a table which contained alpha numeric values like this 1235abcd7412 nofixed length and other row contained abcvd52a1a2 

account
1235abcd7412
abcfd52a1a2
ghti5214ve3
asif214bv2


nofixed length account column plz show me easy query 

thanks 
asif</description>
		<content:encoded><![CDATA[<p>plz help me i have a table which contained alpha numeric values like this 1235abcd7412 nofixed length and other row contained abcvd52a1a2 </p>
<p>account<br />
1235abcd7412<br />
abcfd52a1a2<br />
ghti5214ve3<br />
asif214bv2</p>
<p>nofixed length account column plz show me easy query </p>
<p>thanks<br />
asif</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: asif</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/#comment-52776</link>
		<dc:creator>asif</dc:creator>
		<pubDate>Fri, 05 Jun 2009 16:57:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-user-defined-function-to-extract-only-numbers-from-string/#comment-52776</guid>
		<description>I want to isolate alphanumeric values like
column a values 456abc123def
I want to sepateit</description>
		<content:encoded><![CDATA[<p>I want to isolate alphanumeric values like<br />
column a values 456abc123def<br />
I want to sepateit</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/#comment-50701</link>
		<dc:creator>Imran Mohammed</dc:creator>
		<pubDate>Thu, 09 Apr 2009 02:42:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-user-defined-function-to-extract-only-numbers-from-string/#comment-50701</guid>
		<description>@Hema

select substring ( &#039;50.00 on 04/06/2009&#039;, 1, charindex (&#039;.&#039;, &#039;50.00 on 04/06/2009&#039;)+2)

~IM</description>
		<content:encoded><![CDATA[<p>@Hema</p>
<p>select substring ( &#8216;50.00 on 04/06/2009&#8242;, 1, charindex (&#8216;.&#8217;, &#8216;50.00 on 04/06/2009&#8242;)+2)</p>
<p>~IM</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hema</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/#comment-50689</link>
		<dc:creator>Hema</dc:creator>
		<pubDate>Wed, 08 Apr 2009 20:31:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-user-defined-function-to-extract-only-numbers-from-string/#comment-50689</guid>
		<description>how can i get only amount from this
50.00 on 04/06/2009</description>
		<content:encoded><![CDATA[<p>how can i get only amount from this<br />
50.00 on 04/06/2009</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - Guidelines and Coding Standards Part - 1 Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/#comment-47504</link>
		<dc:creator>SQL SERVER - Guidelines and Coding Standards Part - 1 Journey to SQL Authority with Pinal Dave</dc:creator>
		<pubDate>Thu, 26 Feb 2009 12:14:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-user-defined-function-to-extract-only-numbers-from-string/#comment-47504</guid>
		<description>[...] Always put the DECLARE statements at the starting of the code in the stored procedure. This will make the query optimizer to reuse query plans. (Example) [...]</description>
		<content:encoded><![CDATA[<p>[...] Always put the DECLARE statements at the starting of the code in the stored procedure. This will make the query optimizer to reuse query plans. (Example) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/#comment-45723</link>
		<dc:creator>Imran Mohammed</dc:creator>
		<pubDate>Mon, 19 Jan 2009 06:04:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-user-defined-function-to-extract-only-numbers-from-string/#comment-45723</guid>
		<description>@Reena,

Because the minimum digit is 0 and maximum digit is 9.

Regards,
IM.</description>
		<content:encoded><![CDATA[<p>@Reena,</p>
<p>Because the minimum digit is 0 and maximum digit is 9.</p>
<p>Regards,<br />
IM.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reena</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/#comment-45681</link>
		<dc:creator>Reena</dc:creator>
		<pubDate>Fri, 16 Jan 2009 17:03:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-user-defined-function-to-extract-only-numbers-from-string/#comment-45681</guid>
		<description>SUBSTRING(@String,@Count,1) &lt;= &#039;9&#039;


what is the purpose of 9 here?</description>
		<content:encoded><![CDATA[<p>SUBSTRING(@String,@Count,1) &lt;= &#8216;9&#8242;</p>
<p>what is the purpose of 9 here?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Moreno Vendramin</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/#comment-44404</link>
		<dc:creator>Moreno Vendramin</dc:creator>
		<pubDate>Wed, 26 Nov 2008 10:42:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-user-defined-function-to-extract-only-numbers-from-string/#comment-44404</guid>
		<description>thank you for this article.
It was very helpful to me.

Moreno</description>
		<content:encoded><![CDATA[<p>thank you for this article.<br />
It was very helpful to me.</p>
<p>Moreno</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/#comment-42396</link>
		<dc:creator>Imran Mohammed</dc:creator>
		<pubDate>Thu, 04 Sep 2008 13:43:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-user-defined-function-to-extract-only-numbers-from-string/#comment-42396</guid>
		<description>@Syed,

Please replace the middle part of the query with this, I dont know how the query is changed, this is not the one I posted... I executed this query atleast 10 times befire posting.... There must be something wrong happened while posting my reply, 

anyways I apologize for any inconvenience caused, 

Please replace this query in the end of the code

– This is Actual Script
declare @var int
declare @var2 int
declare @car varchar(100)
declare @len int
declare @res varchar(100)
declare @result varchar(100)
declare @store varchar(100)
set @var = 1
while @var &lt; = ( select count(*) from #result)
begin
select @car = names from #result where id = @var
set @result = ”
set @len = 1
while @len  64 and ascii(@store)  64 and ascii (@store) &lt; 123 -- This is the correct script

set @result = @res+@result
end
set @len= @len+1
end
if @result ”
begin
insert into #results select reverse(@result)
end
set @var= @var+1
end
select * from #results
drop table #results
drop table #result
drop table example123
– End of Script 


Hope this helps.
Imran.</description>
		<content:encoded><![CDATA[<p>@Syed,</p>
<p>Please replace the middle part of the query with this, I dont know how the query is changed, this is not the one I posted&#8230; I executed this query atleast 10 times befire posting&#8230;. There must be something wrong happened while posting my reply, </p>
<p>anyways I apologize for any inconvenience caused, </p>
<p>Please replace this query in the end of the code</p>
<p>– This is Actual Script<br />
declare @var int<br />
declare @var2 int<br />
declare @car varchar(100)<br />
declare @len int<br />
declare @res varchar(100)<br />
declare @result varchar(100)<br />
declare @store varchar(100)<br />
set @var = 1<br />
while @var &lt; = ( select count(*) from #result)<br />
begin<br />
select @car = names from #result where id = @var<br />
set @result = ”<br />
set @len = 1<br />
while @len  64 and ascii(@store)  64 and ascii (@store) &lt; 123 &#8212; This is the correct script</p>
<p>set @result = @res+@result<br />
end<br />
set @len= @len+1<br />
end<br />
if @result ”<br />
begin<br />
insert into #results select reverse(@result)<br />
end<br />
set @var= @var+1<br />
end<br />
select * from #results<br />
drop table #results<br />
drop table #result<br />
drop table example123<br />
– End of Script </p>
<p>Hope this helps.<br />
Imran.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/#comment-42380</link>
		<dc:creator>Imran Mohammed</dc:creator>
		<pubDate>Thu, 04 Sep 2008 05:23:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-user-defined-function-to-extract-only-numbers-from-string/#comment-42380</guid>
		<description>@Syed,

I am sure there must be be another good way of doing the same thing.... I came up with this... This is HIGHLY performance killing query... since this is a while loop under while loop. 

Its your choice if you want to use this...

This does exactly what you want.

Here you go...

-- This is your main table 
create table example123 ( names varchar(max)) 
go
-- Inserting Sample Data 
insert into example123 values ( &#039;AK48148&#039;)
insert into example123 values ( &#039;D144432&#039;)
insert into example123 values ( &#039;MT23432&#039;)
insert into example123 values ( &#039;DT55544&#039;)
insert into example123 values ( &#039;12345&#039;) -- This will not be displayed in the output since it do no have any letter in it

-- This is the output or result table
create table #results ( names varchar(100)) 
go
-- This is our sample original table
create table #result ( id int identity, names varchar(100)) 
go
-- We are copying your data into this sample original table 
insert into #result select names from example123 
go
-- This is Actual Script
declare @var int 
declare @var2 int 
declare @car varchar(100)
declare @len int 
declare @res varchar(100)
declare @result varchar(100)
declare @store varchar(100)
set @var = 1 
while @var &lt; = ( select count(*) from #result)
begin
	select @car = names from #result where id = @var
	set @result = &#039;&#039;
	set @len = 1
			while @len &lt; = ( select len(@car) from #result where id = @var)
			begin
				select @store = substring ( @car, @len, len(@car)) from #result where id = @var
				if ascii( @store)  64
				begin
					select @res = char(Ascii (@store)) from example123 where ascii( @store)   64
					set @result = @res+@result
				end
				set @len= @len+1
			end
	if @result  &#039;&#039;
	begin
	 insert into #results select reverse(@result)
	end
	set @var= @var+1
end
 select * from #results
drop table #results
drop table #result 
drop table example123
-- End of Script 


I am not sure if there is any function already to do this, if you want to change the code, you are more than welcome, if something better can written for same, please post 

Hope this helps,
Imran.</description>
		<content:encoded><![CDATA[<p>@Syed,</p>
<p>I am sure there must be be another good way of doing the same thing&#8230;. I came up with this&#8230; This is HIGHLY performance killing query&#8230; since this is a while loop under while loop. </p>
<p>Its your choice if you want to use this&#8230;</p>
<p>This does exactly what you want.</p>
<p>Here you go&#8230;</p>
<p>&#8211; This is your main table<br />
create table example123 ( names varchar(max))<br />
go<br />
&#8211; Inserting Sample Data<br />
insert into example123 values ( &#8216;AK48148&#8242;)<br />
insert into example123 values ( &#8216;D144432&#8242;)<br />
insert into example123 values ( &#8216;MT23432&#8242;)<br />
insert into example123 values ( &#8216;DT55544&#8242;)<br />
insert into example123 values ( &#8216;12345&#8242;) &#8212; This will not be displayed in the output since it do no have any letter in it</p>
<p>&#8211; This is the output or result table<br />
create table #results ( names varchar(100))<br />
go<br />
&#8211; This is our sample original table<br />
create table #result ( id int identity, names varchar(100))<br />
go<br />
&#8211; We are copying your data into this sample original table<br />
insert into #result select names from example123<br />
go<br />
&#8211; This is Actual Script<br />
declare @var int<br />
declare @var2 int<br />
declare @car varchar(100)<br />
declare @len int<br />
declare @res varchar(100)<br />
declare @result varchar(100)<br />
declare @store varchar(100)<br />
set @var = 1<br />
while @var &lt; = ( select count(*) from #result)<br />
begin<br />
	select @car = names from #result where id = @var<br />
	set @result = &#8221;<br />
	set @len = 1<br />
			while @len &lt; = ( select len(@car) from #result where id = @var)<br />
			begin<br />
				select @store = substring ( @car, @len, len(@car)) from #result where id = @var<br />
				if ascii( @store)  64<br />
				begin<br />
					select @res = char(Ascii (@store)) from example123 where ascii( @store)   64<br />
					set @result = @res+@result<br />
				end<br />
				set @len= @len+1<br />
			end<br />
	if @result  &#8221;<br />
	begin<br />
	 insert into #results select reverse(@result)<br />
	end<br />
	set @var= @var+1<br />
end<br />
 select * from #results<br />
drop table #results<br />
drop table #result<br />
drop table example123<br />
&#8211; End of Script </p>
<p>I am not sure if there is any function already to do this, if you want to change the code, you are more than welcome, if something better can written for same, please post </p>
<p>Hope this helps,<br />
Imran.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Syed</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/#comment-42372</link>
		<dc:creator>Syed</dc:creator>
		<pubDate>Wed, 03 Sep 2008 22:21:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-user-defined-function-to-extract-only-numbers-from-string/#comment-42372</guid>
		<description>Hi Pinal,
I always follow your statement which are really helpful in my work.
I am just wondering if you have function or modify the above function in reverse way. Meaning I would just like to extract the letters from Alphanumeric string.
Like I have a fields like.
AK48148
D144432
MT23432
DT55544

So I want a function that just extract the letters from it.
I would appreciate your time.

Thanks</description>
		<content:encoded><![CDATA[<p>Hi Pinal,<br />
I always follow your statement which are really helpful in my work.<br />
I am just wondering if you have function or modify the above function in reverse way. Meaning I would just like to extract the letters from Alphanumeric string.<br />
Like I have a fields like.<br />
AK48148<br />
D144432<br />
MT23432<br />
DT55544</p>
<p>So I want a function that just extract the letters from it.<br />
I would appreciate your time.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Megistal</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/#comment-36368</link>
		<dc:creator>Megistal</dc:creator>
		<pubDate>Fri, 02 May 2008 14:34:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-user-defined-function-to-extract-only-numbers-from-string/#comment-36368</guid>
		<description>Hi

First of all, thank you for taking time to write t-sql and publish it.

Second, I would like to point out that substring is 1 based instead of 0 based (in SQL 2000 Sp3 at least but should remain the same for other versions as well)

What does it mean? Little beside that 0 based loop one time more than it really need. (One loop is wasted)

The fix? Set @count = 1 for the starting condition instead of @count=0</description>
		<content:encoded><![CDATA[<p>Hi</p>
<p>First of all, thank you for taking time to write t-sql and publish it.</p>
<p>Second, I would like to point out that substring is 1 based instead of 0 based (in SQL 2000 Sp3 at least but should remain the same for other versions as well)</p>
<p>What does it mean? Little beside that 0 based loop one time more than it really need. (One loop is wasted)</p>
<p>The fix? Set @count = 1 for the starting condition instead of @count=0</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tammy Pham</title>
		<link>http://blog.sqlauthority.com/2007/04/11/sql-server-udf-user-defined-function-to-extract-only-numbers-from-string/#comment-5528</link>
		<dc:creator>Tammy Pham</dc:creator>
		<pubDate>Thu, 19 Jul 2007 18:37:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/11/sql-user-defined-function-to-extract-only-numbers-from-string/#comment-5528</guid>
		<description>can you please help me how to extract date and time from string? here is my example:

person A at 2006 345 15:24  See attachment from Ron Holden    person B at 2006 361 16:20  Refer to AR 113831.

i would like output will be like : 2006 345 15:24 

I ready appreciate for all your helped and supported. I looking forward to hear from you soon. 

Big Thanks, 

Tammy</description>
		<content:encoded><![CDATA[<p>can you please help me how to extract date and time from string? here is my example:</p>
<p>person A at 2006 345 15:24  See attachment from Ron Holden    person B at 2006 361 16:20  Refer to AR 113831.</p>
<p>i would like output will be like : 2006 345 15:24 </p>
<p>I ready appreciate for all your helped and supported. I looking forward to hear from you soon. </p>
<p>Big Thanks, </p>
<p>Tammy</p>
]]></content:encoded>
	</item>
</channel>
</rss>
