You are here: Re: Search Char in SQL query « MsSQL Server « IT news, forums, messages
Re: Search Char in SQL query

Posted by jaawaad on 11/02/93 11:52

I think this works for me...i tried this with success so far...

select * from Table where substring(COL2,2,6) Like '%[0-9]')

As i know a char [A-Z] will only appear at position 7 of the string. It
only returns values that are ending with a digit.


Erland Sommarskog wrote:
> (jaawaad@gmail.com) writes:
> > I have a text field in a table that contains number along with chars.
> > Is there a way i can write a query to show all the fields that contains
> > just Numbers or Char in a field??
> >
> > TBALE Example
> >
> > COL1 : COL2(nvarchar)
> > ---------------------------
> > 100 345G01
> > 200 123456789
> > 300 GQ9220
>
> Not really sure what you are looking for, but this query returns all
> rows with digits only in COL2.
>
> SELECT col2
> FROM tbl
> WHERE col2 NOT LIKE '%[^0-9]%'
>
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
>
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

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

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