openrowset for excel:我们可以跳过几行吗?
我将使用以下sql从excel读取数据,但有时我需要跳过前几行。例如,真实数据从第 5 行开始,所以我需要跳过前 4 行,这可行吗?
SELECT *
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0;HDR=YES;Database=c:\daniel\test.xls',
'SELECT * FROM [sheet1$]');
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 rows, is that doable?
SELECT *
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0;HDR=YES;Database=c:\daniel\test.xls',
'SELECT * FROM [sheet1$]');
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用范围 [sheet1$A5:Z] 而不是整个工作表 [sheet1$]
Use a range [sheet1$A5:Z] instead of the entire sheet [sheet1$]
这将对获取的行进行编号,没有特定的顺序(幸运的是):
如果您认为合适,您可能希望通过更改
rownum
定义来指定某种顺序,如下所示:This will number the rows being obtained, with no specific order (as luck would have it):
You may want to specify some order, if you see fit, by changing the
rownum
definition like this: