Importing data from text file via SQL

JapanFreak

Registered User.
Local time
Today, 09:03
Joined
Aug 25, 2007
Messages
45
Dear All,

I have a problem with importing data from a txt file whilst using SQL. The following SQL request works:

Code:
               sSQL = "SELECT Sec, Op1, Tot_Asset, Cash, MKTCAP, EVnow FROM " & TxtFileName(i, j) & _
                        " WHERE Op/(Tot_Asset-Cash)<" & dROICHurdle & _
                        " AND EVnow>-999999999" & _
                        " AND Tot_Asset>-999999999" & _
                        " AND Cash>-999999999"

The code above only retrieves numbers. However, if I add a "WHERE" condition, which should retrieve fields which contain text errors occur. For instance, the following request does not work:

Code:
                sSQL = "SELECT Sec, Op1, Tot_Asset, Cash, MKTCAP, EVnow FROM " & TxtFileName(i, j) & _
                        " WHERE Op/(Tot_Asset-Cash)<" & dROICHurdle & _
                        " AND EVnow>-999999999" & _
                        " AND Tot_Asset>-999999999" & _
                        " AND Cash>-999999999" & _
                        " AND FINOTH=""NONFIN"""

The error message is: "[Microsoft][ODBC Text Driver] Too few parameters. Expected 1."

Does anybody have an idea what the reason is?

Just as an remark: The following request retrieves data from an Access database with similar content and works without any problems:

Code:
                sSQL = "SELECT D.Sec, D.Op1, D.Tot_Asset, D.Cash, D.MKTCAP, D.EVnow" & _
                    " FROM Data AS D" & _
                    " WHERE ((([D].[Op]/([D].[Tot_Asset]-[D].[Cash]))<0.1)" & _
                        " AND ((D.dDate)>" & CDateSQL(dDate1) & ")" & _
                        " AND ((D.dDate)<" & CDateSQL(dDate2) & ")" & _
                        " AND ((D.FINOTH)=""NONFIN""))" & _
                        " AND D.EVnow>-999999999" & _
                        " AND D.Tot_Asset>-999999999" & _
                        " AND D.Cash>-999999999;"

Best regards,
JapanFreak
 
Thank you.

Now it works. Thank you!
 

Users who are viewing this thread

Back
Top Bottom