In SQL how do I exclude a record if there are more than 2 characters after a dash..

In SQL how do I exclude a record if there are more than 2 characters after a dash..

Example I only want to return records that match the following
 AS00000-0

but the table also has recoreds like AD0000-000,AH0000000-00

I need to return only records that have a single digit after the dash
Petek2222Asked:
Who is Participating?
 
Aneesh RetnakaranDatabase AdministratorCommented:
Where num like '%-_'
0
 
Ryan ChongCommented:
try:

select * from yourTable where yourField like '%-0'
0
 
Petek2222Author Commented:
SQl doesn't like that, this is the whole Query. NUM is the table i'm working with

select  
left(NUM,2) as num2,
left(NUM,6) as num1, NUM, dimensioncode =  '1', DESCRIPTION,DATAAREAID
From DIMENSIONS
Where          DATAAREAID = 'coa'
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
SteveCommented:
Underscore should be a single character wildcard. Try this:

select  
left(NUM,2) as num2,
left(NUM,6) as num1, NUM, dimensioncode =  '1', DESCRIPTION,DATAAREAID
From DIMENSIONS
Where          DATAAREAID = 'coa'
AND NUM <> '%-_'
0
 
Petek2222Author Commented:
Perfect, thanks. I didn't know about the underscore
0
 
SteveCommented:
My mistake
AND NUM LIKE '%-_'
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.