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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
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
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
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

Aneesh RetnakaranDatabase AdministratorCommented:
Where num like '%-_'
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Petek2222Author Commented:
Perfect, thanks. I didn't know about the underscore
0
SteveCommented:
My mistake
AND NUM LIKE '%-_'
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.