SQL Server:从 OPENDATASOURCE 中删除 [英] SQL Server: DELETE FROM OPENDATASOURCE

查看:32
本文介绍了SQL Server:从 OPENDATASOURCE 中删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这有效:

SELECT * FROM OPENDATASOURCE( 
       'Microsoft.ACE.OLEDB.12.0', 
       'Data Source=d:\JobFiles\MyFile.xlsx; 
        Extended properties=Excel 8.0')...MySheet$

也是这样:

INSERT INTO OPENDATASOURCE( 
       'Microsoft.ACE.OLEDB.12.0', 
       'Data Source=d:\JobFiles\MyFile.xlsx; 
        Extended properties=Excel 8.0')...MySheet$
SELECT * FROM blahblahblah

那为什么不呢?

DELETE FROM OPENDATASOURCE( 
        'Microsoft.ACE.OLEDB.12.0', 
        'Data Source=d:\JobFiles\MyFile.xlsx;
         Extended properties=Excel 8.0')...MySheet$

我做了一些搜索,但没有真正的运气.归根结底,我需要的只是在插入新数据之前删除 excel 行,我只想使用 SQL 来实现这一点.

I've done some searching with no real luck. At the end of the day, all I need is the excel rows deleted before I can insert fresh data and I want to achieve this with SQL only.

推荐答案

您不能通过 OPENDATASOURCE 删除整行.根据 http://support.microsoft.com/kb/257819:

You cannot delete entire rows via OPENDATASOURCE. According to http://support.microsoft.com/kb/257819:

删除

与删除 Excel 数据相比,您在删除 Excel 数据方面受到更多限制关系数据源.在关系数据库中,行"没有意义或记录"之外的存在;在 Excel 工作表中,这不是真的.您可以删除字段(单元格)中的值.但是,您不能:

You are more restricted in deleting Excel data than data from a relational data source. In a relational database, "row" has no meaning or existence apart from "record"; in an Excel worksheet, this is not true. You can delete values in fields (cells). However, you cannot:

  • 一次删除整个记录,否则您会收到以下错误消息:

此 ISAM 不支持删除链接表中的数据.

您只能通过清空每个记录的内容来删除记录个人领域.

You can only delete a record by blanking out the contents of each individual field.

  • 删除包含 Excel 公式的单元格中的值,否则您会收到以下错误消息:

在这种情况下不允许操作.

  • 您无法删除已删除数据所在的空电子表格行,并且您的记录集将继续显示为空与这些空行对应的记录.

这篇关于SQL Server:从 OPENDATASOURCE 中删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆