I have a list of IDs in a text file like this:
24641985 ,
24641980 ,
24641979 ,
24641978 ,
24641976 ,
24641974 ,
...
...
24641972 ,
24641971 ,
24641970 ,
24641968 ,
24641965)
There's tens of thousands of them.
Now I need to know which ids are in this list, that do not correspond to an ID in my table.
I guess I should put them into a temporary table, then say something like:
select theId
from #tempIdCollection
where theId not in (select customerId from customers)
Problem is I don't know how to get them into the temp table!
Can anyone help? This doesn't have to be efficient. I've just got to run it once. Any solution suggestions welcome!
Thanks in advance!
-Ev
To insert a row into a table, you need to specify three things: First, the table, which you want to insert a new row, in the INSERT INTO clause. Second, a comma-separated list of columns in the table surrounded by parentheses. Third, a comma-separated list of values surrounded by parentheses in the VALUES clause.
I'd use a table variable. You declare it just like a regular variable.
declare @tempThings table (items int)
insert @tempThings values (1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With