|
Posted by Erland Sommarskog on 02/07/06 00:24
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/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]
|