SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Removing Data that has alpha letters
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

hbadministrator
Posting Yak Master

109 Posts

Posted - 01/17/2013 :  14:25:35  Show Profile  Reply with Quote
I have a field that has data with numbers that can very from 3 chars to 8 chars and some have letters in them. I want to eliminate that data from my selections.

example data
Field Name
ccode
1000
1000f
1002
1004f
12321412g
21334123h
1234512f


what is my WHERE statement

WHERE ccode....


Lamprey
Flowing Fount of Yak Knowledge

4354 Posts

Posted - 01/17/2013 :  16:00:03  Show Profile  Reply with Quote
DECLARE @Foo TABLE (Col VARCHAR(10))
INSERT @Foo
VALUES
('ccode'),
('1000'),
('1000f'),
('1002'),
('1004f'),
('12321412g'),
('21334123h'),
('1234512f')

-- NO values with a-z
SELECT *
FROM @Foo
WHERE Col NOT LIKE '%[a-z]%'

--OR, olny values that are 0-9
SELECT *
FROM @Foo
WHERE Col NOT LIKE '%[^0-9]%'

Edited by - Lamprey on 01/17/2013 16:01:14
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000