openrowset for excel: can we skip several rows?

前端 未结 2 617
醉话见心
醉话见心 2020-12-19 00:46

I will use the following sql to read data from excel, but sometimes I need to skip first several rows. e.g the real data begins from line 5, so I need to skip the first 4 ro

2条回答
  •  天涯浪人
    2020-12-19 01:22

    Use a range [sheet1$A5:Z] instead of the entire sheet [sheet1$]

    SELECT *
    FROM OPENROWSET(
        'Microsoft.ACE.OLEDB.12.0',
        'Excel 12.0;HDR=YES;Database=c:\daniel\test.xls',
        'SELECT * FROM [sheet1$A5:Z]'
    );
    

提交回复
热议问题