Groups | Blog | Home
all groups > sql server odbc > june 2005 >

sql server odbc : Query paramaters


Alex
6/16/2005 3:52:10 PM
I am looking for a way to read a seperate .txt file and extract the
paramaters for a query. I am given a .txt file with several thousand numbers
a day, to query against the database. I would very much like to call the
file and read it's contents in as the paramater. Is this possible through
using just sql?

for example,
current method (paraphrased extensively)
select * from emp where emp_number in (1, 2, 3, 4, 5, 6 etc...);

desired method
Alex
6/21/2005 4:59:04 PM
By golley, that works... Thanks.

[quoted text, click to view]
wread NO[at]SPAM online.microsoft.com
6/21/2005 9:46:52 PM
Perhaps you can create a C or C++ program that creates your SELECT stmt at
run time by reading in these values from a text file.

Something along these lines...


char szSqlString[1000];
char szNumbersList[1000];

// Create a function that reads in the list of numbers from a text file and
writes them to 'szNumbersList'...
GetListOfNumbersFromTextFile(szTextFileName, szNumbersList);

snprintf(szSqlString, 1000, "SELECT * from emp where emp_number in ( %s )",
szNumbersList);
SQLExecDirect(hstmt, szSqlString, SQL_NTS);


Alternatively, you could try to do this with parameters, but this would be
MUCH more work.



AddThis Social Bookmark Button