sql – SSIS包不希望获取临时表的元数据

我有一个包含多个流的SSIS包。

每个流程都负责创建一个“分期”表,在创建之后会被填满。
这些表是全局临时表。

我添加了一个额外的流程(我没有制作包),正如上面提到的另外一个表。然而,由于某些原因,该包在此流程上间歇性地失败,而除了某些表名之外,它与其他流程完全相同。

不断弹出的错误:

Update – Insert Data Flow:Error: SSIS Error Code DTS_E_OLEDBERROR. An
OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is
available. Source: “Microsoft SQL Server Native Client 11.0”
Hresult: 0x80004005 Description: “Unspecified error”. An OLE DB
record is available. Source: “Microsoft SQL Server Native Client
11.0” Hresult: 0x80004005 Description: “The metadata could not be determined because statement ‘select * from
‘##TmpMcsConfigurationDeviceHistory86B34BFD041A430E84CCACE78DA336A1” uses a temp table.”.

创作表达:

"CREATE TABLE " + @[User::TmpMcsConfigurationDeviceHistory]  + " ([RecId] [bigint] NULL,[DataAreaID] [nvarchar](4) COLLATE database_default NULL,[Asset] [bigint] NULL,[Code] [nvarchar](255) COLLATE database_default NULL,[Configuration] [bigint],[StartdateTime] [datetime] NULL,[EndDateTime] [datetime] NULL)

解析表达式(=评估):

CREATE TABLE ##TmpMcsConfigurationDeviceHistory764E56F088DC475C9CC747CC82B9E388 ([RecId] [bigint] NULL,[DataAreaID] [nvarchar](4) COLLATE database_default NULL,[Asset] [bigint] NULL,[Code] [nvarchar](255) COLLATE database_default NULL,[Configuration] [bigint],[StartdateTime] [datetime] NULL,[EndDateTime] [datetime] NULL)
Using WITH RESULT SETS to explicitly define the metadata将允许SSIS跳过sp_describe_first_result_set步骤,并使用您定义的元数据。上面的一面是,您可以使用它来获取SSIS来执行包含临时表的SQL(对我来说,性能有很大帮助);缺点是,如果有任何改变,您必须手动维护和更新。

查询示例(存储过程:)

    EXEC ('dbo.MyStoredProcedure')
    WITH RESULT SETS
      (
        (
            MyIntegerColumn INT NOT NULL,
            MyTextColumn VARCHAR(50) NULL,
            MyOtherColumn BIT NULL
        )
      )

查询示例(简单SQL 🙂

EXEC ('
    CREATE TABLE #a 
      (
        Col INT
      ) 
    INSERT INTO #a 
      (
        COL
      )
    SELECT 1 AS Col

    SELECT Col 
    FROM #a')
WITH RESULT SETS ( (Col INT NOT NULL))
  )
翻译自:https://stackoverflow.com/questions/18346484/ssis-package-not-wanting-to-fetch-metadata-of-temporary-table

转载注明原文:sql – SSIS包不希望获取临时表的元数据