简体   繁体   English

执行SQL任务:错误执行查询创建表已存在:SSIS

[英]Execute SQL Task:error Executing the Query Create table already exist:SSIS

I want to create a excel file dynamically so 我想动态创建一个Excel文件,所以

I create a variable CreateExcel and written a query to create a Table 我创建了一个变量CreateExcel并编写了一个查询来创建表

CREATE TABLE `BOL` (
    `CustomerPO` LongText,
    `ShippingNum` LongText,
    `BOL` LongText,
    `PRO` LongText,
    `SSCC_Code` LongText,
    `LineType` LongText,
    `SKU` LongText,
    `Row_Number` LongText,
    `UPCCode` LongText,
 `Location` LongText,    `Quantity` LongText
)

At the first time The Package execute successfully when i run afterwords i am getting error 第一次运行包后,包成功执行时出现错误

[Execute SQL Task] Error: Executing the query "CREATE TABLE BOL ( CustomerPO LongText, `S..." failed with the following error: "Table BOL already exists.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. [执行SQL任务]错误:执行查询“ CREATE TABLE BOL(CustomerPO LongText,`S ...”失败,并显示以下错误:“ Table BOL已存在。”可能的失败原因:查询“ ResultSet”出现问题属性设置不正确,参数设置不正确或连接建立不正确。

before creating a Table you have to check whether it exists in the Database . 在创建Table之前,必须检查它是否存在于Database IF exists drop the Table and re-create it 如果存在,则drop Table并重新创建它

IF EXISTS
(
 SELECT 1
 FROM SYS.TABLES 
 WHERE TYPE = 'U'
 AND NAME = 'BOL'
)
BEGIN
     DROP TABLE BOL
END
GO

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

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