简体   繁体   English

使用SSIS在Excel中清除数据

[英]Clear data in Excel using SSIS

I have created s Stored Procedure in SQL which imports data from a flat file, updates the data and imports the updated data within a table. 我已经在SQL中创建了存储过程,该存储过程从平面文件导入数据,更新数据并在表中导入更新的数据。

After some research, I found that the only way to export this (64bit) table would be to create a SSIS package and use a SQL Job to execute the package. 经过一些研究,我发现导出此(64位)表的唯一方法是创建一个SSIS包并使用SQL Job执行该包。

I have done all of this and managed to get the table data exported but the problem is that it does not clear the data before the import. 我已经完成了所有这些工作,并设法导出了表数据,但是问题是它在导入之前不会清除数据。 I have then created the following 然后,我创建了以下内容

SSIS套件

When dropping the excel table, I have the following SQL Statement : DROP TABLE [Sheet1$] When creating the table, I have the following SQL Statement : 删除excel表时,具有以下SQL语句:DROP TABLE [Sheet1 $]创建表时,具有以下SQL语句:

CREATE TABLE 'Sheet1$' ( BRANCH NVARCHAR(10) , SRCBRANCH NVARCHAR(10) , DEPARTMENT NVARCHAR(10) , GLCODE NVARCHAR(10) , DOCDATE NVARCHAR(10) , VALUE NVARCHAR(50) , ITEMREFERENCE NVARCHAR(100) , MISCREFERENCE NVARCHAR(100) , SUFFIX NVARCHAR(10) , NARRATIVE [NVARCHAR(100) ) GO

After the table has been dropped, it clears all the data together with the header and then fails on the second SQL Task (Create Excel Table) with the following error message: 删除表后,它将清除所有数据以及标题,然后在第二个SQL任务(创建Excel表)上失败,并显示以下错误消息:

[Execute SQL Task] Error: Executing the query "CREATE TABLE 'Sheet1$' (
    BRANCH NVARCHAR(10) ,
    S..." failed with the following error: "Syntax error in CREATE TABLE statement.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

After fail, I cant execute the package due to a validation error. 失败后,由于验证错误,我无法执行该程序包。 This is because my headers in the Excel sheet has been deleted. 这是因为我在Excel工作表中的标题已被删除。

Could someone please point me in the right direction. 有人可以指出我正确的方向。 I have exhausted all options. 我已经用尽了所有选择。

Regards 问候

CREATE TABLE 'Sheet1$' 
(
    BRANCH NVARCHAR(10) ,
    SRCBRANCH NVARCHAR(10) ,
    DEPARTMENT NVARCHAR(10) ,
    GLCODE NVARCHAR(10) ,
    DOCDATE NVARCHAR(10) ,
    VALUE NVARCHAR(50) ,
    ITEMREFERENCE NVARCHAR(100) ,
    MISCREFERENCE NVARCHAR(100) ,
    SUFFIX NVARCHAR(10) ,
    NARRATIVE **[**NVARCHAR(100) 
)
GO

***This is your syntax error. ***这是您的语法错误。 This was asked quite a while ago so I would think you have rectified this by now but I wanted to post for others to know what the issue was. 这个问题是在很久以前问过的,所以我认为您现在已经纠正了这个问题,但是我想发帖让其他人知道问题所在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM