Execute SQL Task in a For loop connector does not execute
Hi all, In one of my ETL I have a For loop In which I use a Variable @vStartDate = '1/1/2007' . I wish to run a for loop from 1/1/2007 to < GetDate() so I kept InitExpression as blank since I have set the value of the variable at the variable declaration only. And EvalExpression as @vStartDate < GetDate(). And assignExpression as @varStartDate = DateAdd("m",1,@varStartDate). I have a Execute SQL task inside the For each loop but it does not execute even once. I couldn't understand the reason for it. I have set the connection & all that is required for the Execute SQL task inside For loop container but it doesn't execute. Please help. Thanks in advance.
February 17th, 2011 7:40am

what is the datatype that you have used for the variable. is it Datetime?My Blog | Ask Me
Free Windows Admin Tool Kit Click here and download it now
February 17th, 2011 7:44am

Yes it is a DateTime Data type. Sorry for the late reply
February 18th, 2011 2:52am

Which SQL Server Version (SSIS) do you have? If 2005, there is a problem with datetime variables for input. I had this problem a few days before, and the best way for me was: declare the variable as string create a new string variable and fill in a Script Task with the whole Statement In SQL Execute Task change the SQLSourceType to "Variable" and select the Variable for SourceVariable This works fine in my porject
Free Windows Admin Tool Kit Click here and download it now
February 18th, 2011 3:41am

I got the issue: InitExpression: @vStartDate = '1/1/2007' EvalExp: @vStartDate < GETDATE() AssignExp: @vStartDate = @vStartDate = DateAdd("m",1,@vStartDate) & not @varStartDate = DateAdd("m",1,@varStartDate) You are using a different variable to assign the value than the variable you are using. It should work now.My Blog | Ask Me
February 18th, 2011 4:25am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics