SQL Query to show data not in table

Hi,
I need your help. I have a query similar to the below with many more customer numbers. Records are showing but some of the customer numbers do not exists in the table, how can I modify the query below so it shows me the customers numbers that do not exist in the table.

Hope the above question makes sense.

select   *
from Customer
where customer_number in ('45212', '85255','25887','4284JK','488555HJK','47852ETH','58641TYR','45870')
jose11auAsked:
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.

Vikas GargAssociate Principal EngineerCommented:
Hello,

I am not getting your query.

What you will achieve by knowing the customer number which are not there  in the customer table.

But you can get a list of customer_number from table
By
Select distinct  customer_number from Customer

You can then insert these multiple values to temp table

and then
do except query

select customer_number from @temptable

except

Select distinct  customer_number from Customer

this will give you the customer_number which are in the select list and not in the customer table

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
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
if your data does not exist in database, how you can select it? : )

to do a quick check, possibly you need to do some hardcoding scripts like:

Select a.* from
(
Select '45212' as customer_number
union
select '85255'
union
select '25887'
union
select '4284JK'
union
select '488555HJK'
union
select '47852ETH'
union
select '58641TYR'
union
select '45870'
) a
where a.customer_number not in
(
select customer_number from Customer
)

alternatively, do as what Vikas Garg had suggested, to insert those customer numbers into a temp table or so, and then you can compare the values accordingly.
jose11auAuthor Commented:
Thank you.
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

From novice to tech pro — start learning today.