Microsoft
Software
Hardware
Network
Question : SSIS Case Statement not executing
Hi Guys,
I am trying to run an SQL SELECT CASE statement in an Execute SQL Task in SSIS and I dont understand why it is erroring.
If i run the following code to prove the varaiable and prarmeters are working fine then it all works okay and I get the variable value in the Items field.
UPDATE ImpPricesSys21 Set Item = ?
Now I want to carry out a specific SQL command to update certain records based on the parameter input. When I run the following
SELECT CASE
WHEN ? = 'E:\Web_FTP_home\WEBPRICED
UMP\001_Pr
ices.txt' THEN UPDATE ImpPricesSys21 SET [Item] = 'AA'
WHEN ? = 'E:\Web_FTP_home\WEBPRICED
UMP\002_Pr
ices.txt' THEN UPDATE ImpPricesSys21 SET [Item] = 'BB'
WHEN ? = 'E:\Web_FTP_home\WEBPRICED
UMP\003_Pr
ices.txt' THEN UPDATE ImpPricesSys21 SET [Item] = 'CC'
END
I get the following error...
Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query "SELECT CASE
WHEN ? = 'E:\Web_FTP_home\WEBPRICED
UM..." failed with the following error: "No value given for one or more required parameters.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
Any thoughts on where I am going wrong?
Look forward to your assistance.
Nigel
Answer : SSIS Case Statement not executing
Correction, select is not required
UPDATE ImpPricesSys21 SET [Item] =
CASE ?
WHEN 'E:\Web_FTP_home\WEBPRICED
UMP\001_Pr
ices.txt' THEN 'AA'
WHEN 'E:\Web_FTP_home\WEBPRICED
UMP\002_Pr
ices.txt' THEN 'BB'
WHEN 'E:\Web_FTP_home\WEBPRICED
UMP\003_Pr
ices.txt' THEN 'CC'
ELSE [Item]
END
Your original WHEN form works as well, but a bit more repetitive with the variable. Also the ELSE preserves [Item] when none of the cases are met, otherwise it is equivalent to the implicit ELSE NULL.
UPDATE ImpPricesSys21 SET [Item] =
CASE
WHEN ? = 'E:\Web_FTP_home\WEBPRICED
UMP\001_Pr
ices.txt' THEN 'AA'
WHEN ? = 'E:\Web_FTP_home\WEBPRICED
UMP\002_Pr
ices.txt' THEN 'BB'
WHEN ? = 'E:\Web_FTP_home\WEBPRICED
UMP\003_Pr
ices.txt' THEN 'CC'
ELSE NULL
END
Random Solutions
SQL
Need help to figure out this Active Directory issue on a new domain with Netlogon issues, in the midst of migration
Gaps between divs
Retrieve value of calculated control on a subform
dual screen monitors look different
Restore default wireless connection on laptop
XPages: can't get a simple dialog box working
Importing a simple spreadsheet into access
HP Proliant DL360
HELO server unrecognized command