﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Discuss Content Posted by Robert Davis / Article Discussions / Article Discussions by Author  / Practical Uses of PatIndex / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 25 May 2013 05:30:20 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Practical Uses of PatIndex</title><link>http://www.sqlservercentral.com/Forums/Topic248565-274-1.aspx</link><description>In your article you say:[quote]Since this article is focusing on practical uses of PatIndex, I will only be checking to see if the string value contains digits only with the exception of allowing it to begin with a negative sign. I will not include checking to see if the value is within the allowable range of the Int data type. [/quote]But even in your test:[code="sql"]Select IsNumeric('-4'), PatIndex('%[^0-9]%', '-4'), dbo.fnIsInt('-4') [/code]It returned 0, so it wasn't doing what you said it was supposed to. (It isn't as simple as just two PatIndex calls.)</description><pubDate>Thu, 31 Mar 2011 17:25:25 GMT</pubDate><dc:creator>UMG Developer</dc:creator></item><item><title>RE: Practical Uses of PatIndex</title><link>http://www.sqlservercentral.com/Forums/Topic248565-274-1.aspx</link><description>Here is a way that I recently found using PATINDEX useful: http://codeslammer.wordpress.com/2008/09/02/sql-server-string-manipulation-removing-non-numeric-characters/I have a column that contains an ID number, but there may be text before and/or after it.  The text is often similar, but it can not be guaranteed that there will be text or not.  However there should only be one number and this is the number I am trying to extract.For example, if you had a column with values such as:"Serial Number: 3078203984-02""SN#472038572289""Serial No. 02-28349-2074"and you just wanted to strip out the unique serial numbers, this is one option to do it.</description><pubDate>Sun, 07 Sep 2008 21:24:29 GMT</pubDate><dc:creator>CodeSlammer</dc:creator></item><item><title>RE: Practical Uses of PatIndex</title><link>http://www.sqlservercentral.com/Forums/Topic248565-274-1.aspx</link><description>Thanks for the comments!! The UDF wasn't intended to be an all encompassing way to determine if a number could be converted to int. The UDF was merely a way to demonstrate how to use PatIndex effectively.</description><pubDate>Wed, 26 Mar 2008 09:32:06 GMT</pubDate><dc:creator>Robert Davis</dc:creator></item><item><title>RE: Practical Uses of PatIndex</title><link>http://www.sqlservercentral.com/Forums/Topic248565-274-1.aspx</link><description>It is a very good post. However, it does not check for the valid range of integer number. For example: 3147483647 will result in true, however, according to sql server, this is not a valid integer because it exceeds the range of integers. ie -2,147,483,648 through 2,147,483,647.It also fails to capture comma separated integers, eg 1,234. This is a valid integer, but the UDF returns false.thanks,Mashiku</description><pubDate>Tue, 25 Mar 2008 18:06:51 GMT</pubDate><dc:creator>mskuyi</dc:creator></item><item><title>RE: Practical Uses of PatIndex</title><link>http://www.sqlservercentral.com/Forums/Topic248565-274-1.aspx</link><description>&lt;P&gt;One of the biggest differences is in application to the text fields. The charindex is not working (only for first 8000) while the patindex is. It returns the position while the like operation doesn't.&lt;/P&gt;</description><pubDate>Tue, 07 Feb 2006 06:33:00 GMT</pubDate><dc:creator>esbob cz</dc:creator></item><item><title>RE: Practical Uses of PatIndex</title><link>http://www.sqlservercentral.com/Forums/Topic248565-274-1.aspx</link><description>&lt;P&gt;Don't see any need for the "IF" at the start of the function.  I wrote an almost identical function for this purpose but with just the WHILE.&lt;/P&gt;</description><pubDate>Mon, 06 Feb 2006 16:00:00 GMT</pubDate><dc:creator>ScottPletcher</dc:creator></item><item><title>RE: Practical Uses of PatIndex</title><link>http://www.sqlservercentral.com/Forums/Topic248565-274-1.aspx</link><description>Difference between using PatIndex and CharIndex, you mean? Good question. I have not done any such testing, but it might make for a good follow up article.</description><pubDate>Mon, 06 Feb 2006 11:37:00 GMT</pubDate><dc:creator>Robert Davis</dc:creator></item><item><title>RE: Practical Uses of PatIndex</title><link>http://www.sqlservercentral.com/Forums/Topic248565-274-1.aspx</link><description>&lt;P&gt;I Wonder if there if there is any difference in performance?  Anyone try any testing?&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;</description><pubDate>Mon, 06 Feb 2006 08:41:00 GMT</pubDate><dc:creator>SuperDBA-207096</dc:creator></item><item><title>RE: Practical Uses of PatIndex</title><link>http://www.sqlservercentral.com/Forums/Topic248565-274-1.aspx</link><description>I just need now to find a need to use this PatIndex tool but it's good to now it exists &lt;img src='images/emotions/wink.gif' height='20' width='20' border='0' title='Wink' align='absmiddle'&gt;Very interresting ! </description><pubDate>Tue, 24 Jan 2006 04:05:00 GMT</pubDate><dc:creator>Christophe Bandini</dc:creator></item><item><title>Practical Uses of PatIndex</title><link>http://www.sqlservercentral.com/Forums/Topic248565-274-1.aspx</link><description>Comments posted to this topic are about the content posted at &lt;A HREF="http://www.sqlservercentral.com/columnists/rdavis/practicalusesofpatindex.asp"&gt;http://www.sqlservercentral.com/columnists/rdavis/practicalusesofpatindex.asp&lt;/A&gt;</description><pubDate>Thu, 05 Jan 2006 11:22:00 GMT</pubDate><dc:creator>Robert Davis</dc:creator></item></channel></rss>