SSIS 套件停止取得臨時表的元資料
在SSIS 套件中,多個串流建立全域臨時表作為資料的暫存區域。然而,一個流在嘗試為其臨時表獲取元資料時遇到間歇性故障。錯誤訊息顯示:
Unspecified error. 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)
解
要解決此問題,請考慮使用WITH RESULT SETS明確定義臨時表的元資料。這允許 SSIS 繞過 sp_describe_first_result_set 步驟並使用提供的元資料。
實作
對於預存程序,請使用以下語法:
EXEC ('dbo.MyStoredProcedure') WITH RESULT SETS ( ( MyIntegerColumn INT NOT NULL, MyTextColumn VARCHAR(50) NULL, MyOtherColumn BIT NULL ) )
對於簡單的SQL 查詢,請使用以下語法:
EXEC (' CREATE TABLE #a ( MyIntegerColumn INT NOT NULL, MyTextColumn VARCHAR(50) NULL, MyOtherColumn BIT NULL ) INSERT INTO #a ( MyIntegerColumn, MyTextColumn, MyOtherColumn ) SELECT 1 AS MyIntegerColumn, ''x'' AS MyTextColumn, 0 AS MyOtherColumn SELECT MyIntegerColumn, MyTextColumn, MyOtherColumn FROM #a') WITH RESULT SETS ( ( MyIntegerColumn INT NOT NULL ,MyTextColumn VARCHAR(50) NULL ,MyOtherColumn BIT NULL ) )
以上是為什麼我的 SSIS 套件無法獲取臨時表的元數據,如何使用'WITH RESULT SETS”修復它?的詳細內容。更多資訊請關注PHP中文網其他相關文章!