views:

41

answers:

2

I have a list of words in a text file. Each word separated by a new line. I want to read all of the words, and then, for each word I have to look up the DB and remove rows that contain the words that were read from the text file. How do i do that? I am a newbie to DB programming and I guess we dont have loops in SQL, right?

1 - Read all the words from the text file 2 - For each word from the text file 3 - Remove entry from db e.d. delete from TABLE where ITEMNAME is like ' WORDFROMFILE'

Thanks

+1  A: 

You could use this technique to read text from file. If you want to do more complicated stuff, I'd suggest doing it from the front end (eg c#/vb etc.) rather than the db

Raze2dust
+1  A: 

Here's the general idea:

Step 1: Import the text file into a table.

Step 2: Write a query that DELETEs from the target table WHERE the keyword = the keyword in the target table, using an INNER JOIN.

Randolph Potter
In defence of my answer, pre-empting all the SQL purists, the use of WHERE can be avoided if the JOIN is written correctly :-)
Randolph Potter