Search code examples
sqlcsvodbc

ERROR [07002] [Microsoft][ODBC Text Driver] Too few parameters. Expected 1


enter image description hereI am having this problem when trying to query the ODBC CSV file. It is coming up with this error message. My plan is to format the date and after this I will start to do the count process based on each day on each AC Serial.

ERROR [07002] [Microsoft][ODBC Text Driver] Too few parameters. Expected 1.It is strange.


SELECT  DSN, Format([Date Time],  "yyyy-MM-dd")
From  a1.csv 
Group by [DSN],Format([Date Time],  "yyyy-MM-dd");`

Solution

  • For those who might have similar issue. If possible it is better to use OLEDB than to use ODBC as data source.The OLEDB Connection string as follow :

    OLE DB Connection String 
    
    Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\temp\\csv;Mode=Read;Extended Properties="text;HDR=YES;FMT=CSVDelimited"
    

    And also the SQL code working now is :

    SELECT        [HC SERIAL CODE], Startdate, COUNT(*) AS Expr2
    FROM            (SELECT DISTINCT DSN, [HC SERIAL CODE], Format([Date time], 'yyyy-MM-dd') AS Startdate
                              FROM            a1.csv) a
    GROUP BY Startdate, [HC SERIAL CODE]
    ORDER BY Startdate