Toad World® Forums

Running Query using CSV file as a reference

Hi There,

Firstly I need to say I am an absolute NOOB when it comes to SQL so please accept that I am about to ask an absolute NOOB question HAHA.

OK here goes…I need a script to run in TOAD that will reference a CSV file saved onto my local hard drive. I’ll try and describe exactly what Ineed to do.

The current script which I use via TOAD on our companies READ ONLY database is this:

SELECT d.number_id,

FROM table.number_t d

WHERE d.number_id IN (‘1230001’, ‘1230002’, ‘1230003’)

This will return a result for each number that exists within the table.number table along with the status of each number i.e. active or inactive. A very basic query.

What I need to be able to do is run that query but instead of having to copy each number into TOAD manually, I need TOAD to check a .csv file ofsaid numbers and then return the results.

So I imagine the query would look something like:

SELECT d.number_id,

FROM table.number_t d

WHERE d.number_id IN (check file c:\numbersfile.csv)

I have no idea how to make this work and I cannot find anything online anywhere that does’nt require some sort of “write” to the database. Its astrictly read only query - I do not require the output to be created toan external file as I can export the result via TOAD.

Any help here would be greatly appreciated. Thanks.


Hi Mark,

I’m afraid Toad can not behave the way you want it.
Why it is pain for you to create IN condition in the query?
Probably there is a way for you to create a temporary table with required IDs and then use regular t-sql.