You are here: Re: selecting only numeric data from a string « MsSQL Server « IT news, forums, messages
Re: selecting only numeric data from a string

Posted by KenJ on 01/12/06 05:45

len(@TestData) causes it to take the entire string after the first
number. you need to trim this down by the length of your number...

SELECT substring(@TestData, patindex('%[0-9]%', @TestData),
len(@TestData) - patindex('%[0-9]%', @TestData) - patindex('%[0-9]%',
reverse(@TestData)) + 2)

Tim Groulx wrote:
> Hello,
>
> I need to be able to select only the numeric data from a string that is
> in the form of iFuturePriceID=N'4194582'
>
> I have the following code working to remove all the non-numeric text
> from before the numbers, but it is still leaving the single quote after
> the numbers, i.e. 4194582'
>
> Any ideas or suggestions how to accomplish that? Thanks in advance.
>
> Declare @TestData varchar(29)
> Set @TestData = "iFuturePriceID=N'4194582'"
> Select Substring(@TestData, patindex('%[0-9]%', @TestData),
> Len(@TestData))
>
> TGru
>
> *** Sent via Developersdex http://www.developersdex.com ***

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация