View Single Post

   
  #2 (permalink)  
Old 02-29-2008, 06:19 PM
Erland Sommarskog
 
Posts: n/a
Default Re: Searching/Estracting numerical data

KR (kraman@bastyr.edu) writes:
> I am new to the SQL world, and I am trying to come up with a script
> that will extract only the numerical data from a column of varchar
> data type . There is not a pattern to the data entered, except that
> the data that
> I am looking to extract is a three digit number. If someone could
> point me in the right direction that would be great.


SELECT cast(col as int) FROM tbl WHERE col LIKE '[0-9][0-9][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