Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Eliminating Numerics from a Result Set (EASY)

Author  Topic 

funk.phenomena
Posting Yak Master

121 Posts

Posted - 2012-02-21 : 12:18:33
Hi All - I have the following table:
[CODE]
MODEL

ASUS_P101
ACER_X5
ACER_43497MX_GT
2610
3597799
359784946
359797746
GIGABYTE_MXGT
X7
[/CODE]
I need run a query that excludes based on two conditions (AND):

(A) Entirely Numeric AND (B) Length >= 6 characters

Output would be as follows:
[CODE]
ASUS_P101
ACER_X5
ACER_43497MX_GT
2610
GIGABYTE_MXGT
X7
[/CODE]
Can you help me out:

[CODE]
SELECT MODEL FROM TABLE1
WHERE LEN(MODEL) >=6 AND MODEL NOT LIKE ?????
[/CODE]


tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-02-21 : 12:49:15
Use IsNumeric(MODEL) = 1 for A.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-21 : 13:46:59
[code]
SELECT MODEL FROM TABLE1
WHERE LEN(MODEL) >=6 AND MODEL LIKE '%[^0-9]%'
[/code]




------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -