ResonantEcho
Programmer
Table1:
Column: DebtID
Sample Value: G2010090058868
Table 2:
Column: IndexValue
Sample Value: prom~000000000~a~DCMS02~GRAYLG_0002101985~~~~~11/17/2009~~~0002101985~G2010090058868~~~~~00000129.001
I need to list all the "DebtID"s in "Table 1" that do not exist in "Table 2". Unfortunately, "Table 2" does not have a "DebtID" column. However, the "DebtID" can be found in the "IndexValue" column in "Table 2". Weird, I know. But this is what I have to work with.
I know I can use LIKE or CHARINDEX to find if there is a match.
select indexvalues
from table2 with (nolock)
where charindex('G2010090058868', indexvalues) > 0
However, what is the most efficient query to use (subquery or join) to list ALL the "DebtID"s that do not exist in "Table 2"? Since it's not a simple column to column join I'm not sure how to do this.
Thanks for your help in advance. I'm new to the SQL world. Everything I've tried either hasn't worked or takes way to long to pull back a result. There is an INDEX on both columns mentioned.
Column: DebtID
Sample Value: G2010090058868
Table 2:
Column: IndexValue
Sample Value: prom~000000000~a~DCMS02~GRAYLG_0002101985~~~~~11/17/2009~~~0002101985~G2010090058868~~~~~00000129.001
I need to list all the "DebtID"s in "Table 1" that do not exist in "Table 2". Unfortunately, "Table 2" does not have a "DebtID" column. However, the "DebtID" can be found in the "IndexValue" column in "Table 2". Weird, I know. But this is what I have to work with.
I know I can use LIKE or CHARINDEX to find if there is a match.
select indexvalues
from table2 with (nolock)
where charindex('G2010090058868', indexvalues) > 0
However, what is the most efficient query to use (subquery or join) to list ALL the "DebtID"s that do not exist in "Table 2"? Since it's not a simple column to column join I'm not sure how to do this.
Thanks for your help in advance. I'm new to the SQL world. Everything I've tried either hasn't worked or takes way to long to pull back a result. There is an INDEX on both columns mentioned.