Search code examples
sqlexcelrsqlcommandimport-from-excel

sql command for reading a particular sheet, column


This is probably a very stupid question for SQL stalwarts, but I just want one SQL command.

Details,

I am using a data analysis tool called R, this tool uses ODBC to read data from XLS. I am now trying to read data from an XLS file. The ODBC tool in R accepts SQL commands.

Question,

Can someone give me an SQL command that will read data from an XLS file's - Specified sheet - Specified column [by name] - Specified row [Specified just by Row Index]

Thanks ...


Solution

  • Once you have set the connection to the file, you can use following statement:

    select [columnname] from [sheetname$] where [columnname] = 'somevalue'
    

    Not sure about the row index thing. But you can make use of where clause if each row in the file has serial number or any such unique value.