View Single Post

   
  #5 (permalink)  
Old 02-29-2008, 07:53 PM
Erland Sommarskog
 
Posts: n/a
Default Re: Search Char in SQL query

(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/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Reply With Quote