troubleshooting Question

Is it possible to write a T-SQL for this?

Avatar of vdesai_8
vdesai_8 asked on
Microsoft SQL Server 2005Microsoft SQL Server 2008SQL
7 Comments1 Solution265 ViewsLast Modified:
Dear Gurus,

The objective of this SQL statement is to find potential duplicate values by comparing the list of accountnumbers(given by a manager) with the accountnumbers in "table1".

Table1
_______
82244567
00082244567
93466666
123456
0088888888
88888888

Given values(by a manager) that we need to compare:
______________
82244567
88888888

My current T-SQL:
______________
*******************************************************
Select *
from table1
where acctnumber like '%82244567'

Result:
_______
82244567
00082244567
********************************************************

Select *
from table1
where acctnumber like '%88888888'

Result:
______
0088888888
88888888

*********************************************************

As can be seen above, I have to execute the same Sql statement for each account number in the given list inorder to find a potential duplicate.

Is there a way that I can handle all the given accounts in a single SQL and find the duplicate values?
something like,

Select *
from table1
where acctnumber like in ( '%88888888', '%82244567')

Please advise. Thanks for your help in advance.


 
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros