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
BES 5.0.1 and Exchange 2010
HP Desktop memory
Logic puzzle
SBS 2008 reporting shows wrong amount of sent emails
namespace question
2 factor authentication
Cisco Switch not configured with TACACS asks for username?
RDP using SBS 2003
How do i stop computer from crashing with code Ox0000001A
Formview - System.NullReference Exception when using findcontrol