Link to home
Start Free TrialLog in
Avatar of rwheeler23
rwheeler23Flag for United States of America

asked on

SSIS Scripting error

I am using SSIS 2012 with VS 2013. I have variable defind as a SQL statement with this where clause. When I run the package I keep getting the message "Incorrect syntax neat the keyword 'And'.". If I evaluate the expression within the project and run it in SSMS it runs just fine. Does anyone see anything wrong with this Where clause? All the variables have defined values.

WHERE YEAR(a.TRXDATE)*10000+MONTH(a.TRXDATE)*100+DAY(a.TRXDATE) >= " + @[User::FiscalPeriod] + (@[User::LoadFuturePer]
== "Y"?";":" And YEAR(a.TRXDATE)*10000+MONTH(a.TRXDATE)*100+DAY(a.TRXDATE) <=  " + @[User::CurrentPeriod] + ";")
Avatar of Vikas Garg
Vikas Garg
Flag of India image


I am not getting this == "Y"?";":"

If we are using execute sql task we can pass parameter using ?

But in script task we need to declare a variable and pass the value accordingly
Avatar of rwheeler23


I have several SSIS packages that use this script. All I do is modify the body of the SQL statement and I have never needed to adjust the Where clause. I have attached the entire statement. Are you saying that I should remove the ?
By the way, this is a data flow task. I am extracting data out of one database and inserting it into another.
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This package was given to me and works in all other cases. I actually rewrote the date range part so if did not need this construct in the where clause. I think this issue is data driven and in this case the condition is causing this portion of the code to be executed.
Thanks for the tips.