简体   繁体   English

参数未创建临时表的SSIS SQL任务

[英]SSIS SQL Task with parameters not creating temp table

I've got a SQL task that creates a temp table, then a data flow task that selects from that temp table. 我有一个创建临时表的SQL任务,然后是从该临时表中选择的数据流任务。 Everything works fine and dandy, but when I add a parameter to the SQL task, the data flow task fails, saying the temp table wasn't created. 一切正常且繁琐,但是当我向SQL任务添加参数时,数据流任务失败,并说没有创建临时表。 Hard coding the parameter values works. 硬编码参数值有效。

The retain same connection option is true, metadata is set, and my Int32 variables are mapped as long with names 0 and 1 and size -1 for oledb. 保留相同的连接选项为true,设置了元数据,并且将我的Int32变量映射为oledb,名称为0和1,大小为-1。

I've managed to replicate it on a smaller scale 我设法将其复制到较小的规模

SQL Task SQL任务

DECLARE @Yesterday DATETIME
DECLARE @Today DATETIME

DECLARE @StartDisposition INT = ?
DECLARE @EndDisposition INT = ?

SET @Yesterday = CONVERT (date, DATEADD(day, @StartDisposition, GETDATE()))
SET @Today = CONVERT (date, DATEADD(day, @EndDisposition, GETDATE()))

SELECT @StartDisposition AS A, @Yesterday AS B, @Today AS C INTO #TempT

Data Flow Task, or just a SQL Task for this purpose 数据流任务,或者仅是一个SQL任务

SELECT * FROM #TempT

So something with the parameters seems to be messing up the creation of the temp table. 因此,带有参数的东西似乎使temp表的创建变得混乱。

Thanks 谢谢

Using a String variable expression for the query worked. 使用String变量表达式进行查询有效。 Here's how it went. 这是怎么回事。

"DECLARE @Yesterday DATETIME
DECLARE @Today DATETIME

DECLARE @StartDisposition INT = " + (DT_STR, 20, 1252)@[User::StartDisposition] + "
DECLARE @EndDisposition INT =  " + (DT_STR, 20, 1252)@[User::EndDisposition] + "

SET @Yesterday = CONVERT (date, DATEADD(day, @StartDisposition, GETDATE()))
SET @Today = CONVERT (date, DATEADD(day, @EndDisposition, GETDATE()))

SELECT @StartDisposition AS A, @Yesterday AS B, @Today AS C INTO #TempT"

Then in the SQL Task you change the SQLSourceType to Variable 然后在SQL任务中,将SQLSourceType更改为Variable

Thanks for your help everyone. 谢谢大家的帮助。

有时候很奇怪,但是如果我们创建全局临时表(## TempT)可以解决

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

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