我有一条select语句,在其中创建了2个临时表并在select插入之前进行插入,然后从这些临时表中获取数据,从而在它们之间建立连接。我希望元数据成为最终选择。在ssms中,它运行良好,在ssis中,我不知道为什么会抛出该错误。查询是这样的:
CREATE TABLE #Per (PerID bigint NOT NULL......) CREATE TABLE #Pre (PerID bigint NOT NULL, IsWorking.......) INSERT INTO #Per SELECT .... FROM ..... INSERT INTO #Pre SELECT .... FROM ..... SELECT * FROM #Per per LEFT JOIN #Pre pre ON per.PerID = pre.PerID
我已经测试了所有语句以确保它们和整个查询正常工作,并向我返回了数据,但是ssis抛出了错误:
The metadata could not be determined because statement 'INSERT INTO #Per SELECT ...... uses a temp table.". Error at project_name [646]: Unable to retrieve column information from the data source. Make sure your target table in the database is available.
尝试使用表变量代替类似:
DECLARE @Per TABLE (PerID bigint NOT NULL......) DECLARE @Pre TABLE (PerID bigint NOT NULL, IsWorking.......) INSERT INTO @Per SELECT .... FROM ..... INSERT INTO @Pre SELECT .... FROM ..... SELECT * FROM @Per per LEFT JOIN @Pre pre ON per.PerID = pre.PerID
应该工作正常